/* AgriSupplyAI - Premium Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;700&display=swap');

:root {
    --primary: #1B5E35;
    --primary-light: #52B788;
    --primary-dark: #0D3B1E;
    /* Premium Theme Variables */
    --green-dark: #0D3B1E;
    --green-main: #1B5E35;
    --green-mid: #2D7A4F;
    --green-light: #52B788;
    --gold: #D4A017;
    --gold-light: #FFD166;
    --gold-pale: #FFF3CC;
    --secondary: #D4A017;
    --accent: #FFD166;
    --bg-light: #F8FAF5;
    --bg-dark: #0D3B1E;
    --text-main: #0D3B1E;
    --text-muted: #5A7060;
    --white: #FFFFFF;
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow: 0 8px 32px 0 rgba(13, 59, 30, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

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

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

/* Layout Utilities */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

.section-padding {
    padding: 80px 0;
}

/* Button Component */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    gap: 8px;
    font-family: 'Outfit', sans-serif;
}

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

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(45, 106, 79, 0.2);
}

.btn-secondary {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: var(--white);
}

/* Navigation */
nav {
    height: 80px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
}

nav.scrolled {
    background: var(--green-dark);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    height: 70px;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo img {
    height: 42px;
    border-radius: 6px;
    object-fit: contain;
}
.sidebar-logo {
    height: 38px;
    border-radius: 6px;
    object-fit: contain;
}
.footer-logo-img {
    height: 60px;
    margin-bottom: 20px;
}
.card-logo {
    height: 40px;
    border-radius: 8px;
}

.nav-links {
    display: flex;
    gap: 32px;
    align-items: center;
}

.nav-links a {
    color: rgba(255,255,255,0.85);
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--gold-light);
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gold);
    border-radius: 2px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.reveal {
    animation: fadeIn 0.8s ease forwards;
}

/* Responsive Grid */
.grid {
    display: grid;
    gap: 24px;
}

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

@media (max-width: 992px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .nav-links, .nav-actions { display: none; }
    .mobile-nav-btn { display: block !important; }
}

@media (max-width: 600px) {
    .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   PORTAL RESPONSIVE SYSTEM — Admin Portal Global Styles
   Applies to all admin pages. Breakpoints: 1024px / 768px / 480px
   ============================================================ */

/* ------ Animated Hamburger Button ------ */
.mobile-nav-btn {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 0.25s, transform 0.2s;
    flex-shrink: 0;
}
.mobile-nav-btn:hover { background: rgba(255,255,255,0.2); }
.mobile-nav-btn:active { transform: scale(0.92); }

/* Three-bar icon drawn as pseudo-elements + span */
.mobile-nav-btn .bar {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s, width 0.3s;
    transform-origin: center;
}
/* Animate to X on .open */
.mobile-nav-btn.open .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-nav-btn.open .bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.mobile-nav-btn.open .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ------ Mobile Top Header Bar ------ */
.portal-mobile-header {
    display: none;  /* becomes flex via media query */
    width: 100%;
    background: #0D1B2A;
    color: #fff;
    padding: 12px 20px;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1100;
    box-shadow: 0 2px 20px rgba(0,0,0,0.4);
    flex-shrink: 0;
}
.portal-mobile-header .nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.portal-mobile-header .nav-brand img {
    height: 34px;
    border-radius: 6px;
}
.portal-mobile-header .nav-brand span {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    color: #40916C;
}

/* ------ Dark Overlay behind open sidebar ------ */
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1040;
    display: none;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.mobile-overlay.active { display: block; }

/* ------ Sidebar always has smooth transition ------ */
.sidebar {
    transition: left 0.32s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ==========================================
   TABLET / SMALL DESKTOP  ≤ 1024px
   ========================================== */
@media (max-width: 1024px) {

    /* KEY FIX: body becomes a column so the sticky header
       appears ABOVE the content, not beside the sidebar */
    body {
        flex-direction: column !important;
    }

    /* Mobile header appears as a full-width top row */
    .portal-mobile-header {
        display: flex !important;
        order: -1; /* always first child */
    }
    .mobile-nav-btn { display: flex !important; }

    /* Sidebar: fixed, off-screen to the left */
    .sidebar {
        left: -320px !important;
        transform: none !important;
        z-index: 1050 !important;
        top: 0 !important;
        box-shadow: none;
    }
    .sidebar.active {
        left: 0 !important;
        box-shadow: 20px 0 70px rgba(0, 0, 0, 0.45);
    }

    /* Main content: full width, no left margin */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 25px !important;
        flex: 1;
    }

    /* Stat card grids: 2-column on tablet */
    .stats-grid,
    .insight-grid,
    .dashboard-grid,
    .admin-stats,
    .product-grid,
    .stats-strip,
    .p-grid,
    .products-grid,
    .summary-cards,
    .kpi-row {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Page headers wrap */
    .page-header,
    .top-bar,
    .dashboard-header,
    .header {
        flex-wrap: wrap !important;
        gap: 14px !important;
    }

    /* Controls rows wrap */
    .controls-row,
    .top-bar-controls {
        flex-wrap: wrap !important;
        width: 100% !important;
    }
    .controls-row .form-control,
    .top-bar-controls .form-control {
        flex: 1;
        min-width: 140px;
    }
}

/* ==========================================
   MOBILE  ≤ 768px
   ========================================== */
@media (max-width: 768px) {
    .main-content { padding: 16px !important; }

    /* 1-column stacking on mobile */
    .stats-grid,
    .insight-grid,
    .dashboard-grid,
    .admin-stats,
    .product-grid,
    .stats-strip,
    .p-grid,
    .products-grid,
    .summary-cards,
    .kpi-row,
    .analytics-grid,
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* Modals become bottom sheets */
    .modal-box,
    .modal-content {
        max-width: 100% !important;
        border-radius: 24px 24px 0 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        max-height: 92vh !important;
        overflow-y: auto !important;
        animation: slideUpSheet 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    }
    @keyframes slideUpSheet {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0);   opacity: 1; }
    }

    /* Tables scroll horizontally */
    table { min-width: 680px; }
    .card, .table-container { overflow-x: auto; }

    /* Modal footer buttons stack */
    .modal-footer { flex-direction: column; gap: 10px; }
    .modal-footer .btn { width: 100%; justify-content: center; }

    /* Public nav fix */
    nav .container { padding: 0 16px; }
    .header, .dashboard-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    /* Shrink page titles */
    .page-header h1 { font-size: 1.5rem !important; }
    .top-bar h1    { font-size: 1.2rem !important; }
}

/* ==========================================
   SMALL PHONES  ≤ 480px
   ========================================== */
@media (max-width: 480px) {
    .main-content { padding: 12px !important; }
    .card { padding: 16px !important; border-radius: 16px !important; }
    .btn  { padding: 10px 16px !important; font-size: 0.88rem !important; }

    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header .btn,
    .top-bar .btn { width: 100%; justify-content: center; }

    .stats-grid,
    .insight-grid,
    .admin-stats,
    .kpi-row,
    .summary-cards { grid-template-columns: 1fr !important; }

    .portal-mobile-header { padding: 10px 15px; }
    .portal-mobile-header .nav-brand span { font-size: 1rem; }
}



/* Public Mobile Menu Dropdown */
.mobile-menu-overlay {
    position: fixed;
    top: 85px;
    right: 5%;
    width: 260px;
    max-height: 80vh;
    overflow-y: auto;
    background: #fff;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(13, 59, 30, 0.15);
    border: 1px solid rgba(0,0,0,0.06);
    padding: 10px 20px 20px;
    height: auto;
    gap: 0;
}
.mobile-menu-overlay.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}
.mobile-menu-overlay a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #1e293b;
    font-size: 1rem;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    margin: 0;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    transition: 0.2s;
}
.mobile-menu-overlay a i {
    font-size: 1.3rem; /* Yellow icons */
    color: #FFB703;
    width: 24px;
    text-align: center;
}
.mobile-menu-overlay a:last-child {
    border-bottom: none;
    border-radius: 8px;
}
.mobile-menu-overlay a:hover {
    color: #1B5E35;
    padding-left: 8px;
}
.hamburger i {
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.close-menu {
    display: none;
}

/* Custom Styled Dropdowns */
select.form-control, select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231B5E35' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding: 12px 40px 12px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: #1e293b;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
}

select.form-control:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 94, 53, 0.15);
}

select.form-control:disabled, select:disabled {
    background-color: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* Remove default IE arrow */
select::-ms-expand {
    display: none;
}
