/* بوابة الموردين - Mobile-First Design */

:root {
    --primary-color: #1E7F45;
    --primary-dark: #155A32;
    --primary-light: #28A55F;
    --bg-cream: #FBF7EE;
    --bg-white: #FFFFFF;
    --text-dark: #1F2937;
    --text-gray: #6B7280;
    --border-color: #E5E7EB;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-cream);
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 16px;
    min-height: 100vh;
    padding-bottom: 80px; /* مساحة لـ bottom nav */
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 16px;
}

/* ===== MOBILE HEADER ===== */
.mobile-header {
    background-color: var(--bg-white);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-header h1 {
    font-size: 1.125rem;
    color: var(--primary-color);
    margin: 0;
}

.mobile-header .supplier-name {
    font-size: 0.875rem;
    color: var(--text-gray);
    margin: 0;
}

/* إخفاء navbar القديم */
.navbar {
    display: none;
}

/* ===== BOTTOM NAVIGATION BAR ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-white);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 56px;
    padding: 6px 12px;
    text-decoration: none;
    color: var(--text-gray);
    transition: all 0.2s;
    border-radius: 8px;
}

.bottom-nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bottom-nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

.bottom-nav-item.active {
    color: var(--primary-color);
    background-color: rgba(30, 127, 69, 0.1);
}

.bottom-nav-item:active {
    transform: scale(0.95);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: 16px 0;
    min-height: calc(100vh - 140px);
}

/* ===== LOGIN PAGE ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--bg-white);
    padding: 32px 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 24px;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.938rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px; /* منع auto-zoom في iOS */
    font-family: 'Tajawal', sans-serif;
    transition: border-color 0.3s;
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
    min-height: 48px; /* Touch target */
    line-height: 1.2;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:active {
    background-color: var(--primary-dark);
    transform: scale(0.98);
}

.btn-secondary {
    background-color: var(--text-gray);
    color: white;
}

.btn-sm {
    padding: 10px 20px;
    font-size: 0.875rem;
    min-height: 44px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.938rem;
}

.alert-error {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.alert-success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #6EE7B7;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.card-title {
    font-size: 1.25rem;
    color: var(--primary-color);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--bg-cream);
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    padding: 20px 16px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.stat-card h3 {
    font-size: 2rem;
    margin-bottom: 4px;
    font-weight: 700;
}

.stat-card p {
    font-size: 0.875rem;
    opacity: 0.95;
    margin: 0;
}

.stat-card.secondary {
    background: linear-gradient(135deg, #6B7280 0%, #9CA3AF 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, #F59E0B 0%, #FBBF24 100%);
}

/* ===== PRODUCT/ORDER CARDS (بدل الجداول) ===== */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: transform 0.2s;
}

.item-card:active {
    transform: scale(0.98);
}

.item-image {
    width: 80px;
    height: 80px;
    min-width: 80px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: var(--bg-cream);
}

.item-image-placeholder {
    width: 80px;
    height: 80px;
    min-width: 80px;
    border-radius: 12px;
    background: var(--bg-cream);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-gray);
    text-align: center;
    padding: 4px;
    border: 2px solid var(--border-color);
}

.item-content {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
    line-height: 1.3;
}

.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.item-meta-item {
    font-size: 0.875rem;
    color: var(--text-gray);
}

.item-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
}

.item-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

/* ===== TOGGLE SWITCH (حجم أكبر للموبايل) ===== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 64px;
    height: 36px;
    min-width: 64px;
    min-height: 36px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 36px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 28px;
    width: 28px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--success);
}

input:checked + .slider:before {
    transform: translateX(28px);
}

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.813rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

/* ===== FILTERS ===== */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filters::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-white);
    border-radius: 24px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    color: var(--text-dark);
    white-space: nowrap;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.filter-btn:active {
    transform: scale(0.95);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== SEARCH BOX ===== */
.search-box {
    width: 100%;
    margin-bottom: 16px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    font-family: 'Tajawal', sans-serif;
}

/* ===== ORDER DETAIL - PRODUCT ITEMS ===== */
.order-product-card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 12px;
}

.order-product-image {
    width: 60px;
    height: 60px;
    min-width: 60px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid var(--border-color);
}

.order-product-content {
    flex: 1;
}

.order-product-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
    line-height: 1.3;
}

.order-product-quantity {
    font-size: 0.938rem;
    color: var(--text-gray);
    margin-bottom: 6px;
}

.order-product-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ===== INFO SECTIONS ===== */
.info-section {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.info-section h4 {
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 12px;
}

.info-section p {
    margin-bottom: 8px;
    font-size: 0.938rem;
}

.info-section p:last-child {
    margin-bottom: 0;
}

/* ===== TOTAL SUMMARY ===== */
.total-summary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    padding: 20px;
    border-radius: 16px;
    margin: 16px 0;
    box-shadow: var(--shadow-md);
}

.total-summary-label {
    font-size: 0.938rem;
    opacity: 0.9;
    margin-bottom: 4px;
}

.total-summary-amount {
    font-size: 1.75rem;
    font-weight: 700;
}

/* ===== FOOTER ===== */
.footer {
    background-color: var(--bg-white);
    padding: 20px 16px;
    text-align: center;
    color: var(--text-gray);
    font-size: 0.875rem;
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-gray);
}

.empty-state h3 {
    color: var(--text-dark);
    margin-bottom: 8px;
    font-size: 1.125rem;
}

.empty-state p {
    font-size: 0.938rem;
}

/* ===== UTILITIES ===== */
.text-center {
    text-align: center;
}

.mb-16 {
    margin-bottom: 16px;
}

.mt-16 {
    margin-top: 16px;
}

/* ===== TABLET & DESKTOP (min-width: 768px) ===== */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
        padding: 0 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }

    .bottom-nav {
        display: none;
    }

    .navbar {
        display: block;
    }

    .mobile-header {
        display: none;
    }

    body {
        padding-bottom: 0;
    }

    .items-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 960px;
    }

    .items-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}
