:root {
    /* Brand Colors - Golden Theme */
    --primary: #FFD700;
    /* Gold */
    --primary-dark: #E6C200;
    /* Darker Gold for hover */
    --primary-text: #2D3748;
    /* Dark text for contrast on Gold */

    --secondary: #718096;
    --success: #48BB78;
    --info: #4299E1;
    --warning: #ECC94B;
    --danger: #F56565;

    /* Backgrounds & Surfaces (Softer Whites) */
    --bg-body: #F7FAFC;
    /* slightly cool gray/white */
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-input: #EDF2F7;

    /* Text */
    --text-main: #2D3748;
    --text-muted: #718096;
    --text-white: #FFFFFF;

    /* Borders & Shadows */
    --border-color: #E2E8F0;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #FFD700 0%, #F6AD55 100%);
    /* Gold -> Orange */
    --gradient-success: linear-gradient(135deg, #48BB78 0%, #38A169 100%);
    --gradient-info: linear-gradient(135deg, #4299E1 0%, #3182CE 100%);
    --gradient-danger: linear-gradient(135deg, #F56565 0%, #C53030 100%);
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --bg-body: #171923;
    /* Very dark gray */
    --bg-card: #2D3748;
    --bg-sidebar: #283041;
    --bg-input: #4A5568;

    --text-main: #E2E8F0;
    --text-muted: #A0AEC0;

    --border-color: #4A5568;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);

    /* Adjust primary for dark mode so it's not too bright? or keep it pop? 
       Gold pops nicely on dark. */
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* --- Layout --- */
.app-container {
    display: flex;
    width: 100%;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    transition: transform 0.3s ease;
    z-index: 200;
}

.brand {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--gradient-primary);
    color: var(--primary-text);
    /* Dark text on Gold */
}

.brand h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin: 0;
    color: var(--text-main);
}

/* Navigation - Accordion Style */
.nav-menu {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 2rem;
}

.nav-menu ul {
    list-style: none;
}

/* Accordion Header (Sector) */
.nav-category {
    padding: 0.85rem 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
    user-select: none;
    font-size: 0.9rem;
    /* Slightly smaller for density */
    letter-spacing: 0.02em;
}

.nav-category:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.nav-category .arrow {
    font-size: 0.7rem;
    transition: transform 0.3s;
    opacity: 0.5;
}

.nav-category.active-cat {
    background-color: rgba(255, 215, 0, 0.15);
    /* light gold tint */
    color: #B7950B;
    /* Darker Gold Text */
}

.nav-category.active-cat .arrow {
    transform: rotate(180deg);
}

/* Submenu Items */
.nav-item-group {
    padding:0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: rgba(0, 0, 0, 0.02);
}

.nav-item-group.open {
    padding: 1rem 0;
    max-height: 500px;
    /* arbitrary large height */
    border-bottom: 1px solid var(--border-color);
}

.nav-item {
    padding: 0.9rem 1.5rem 0.9rem 2.5rem;
    /* Increased padding */
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.95rem;
    /* Larger font */
    display: flex;
    align-items: center;
    gap: 12px;
    /* More gap */
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: var(--text-main);
}

.nav-item.active {
    color: var(--text-main);
    background-color: rgba(255, 215, 0, 0.2);
    border-left-color: var(--primary);
    font-weight: 600;
}
.menu-item{
    padding: 0.9rem 1.5rem 0.9rem 2.5rem;
    /* Increased padding */
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.95rem;
    /* Larger font */
    display: flex;
    align-items: center;
    gap: 12px;
    /* More gap */
    border-left: 3px solid transparent;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    /* matches sidebar width */
    display: flex;
    flex-direction: column;
    width: calc(100% - 260px);
    transition: margin-left 0.3s ease;
}

/* Topbar */
.topbar {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

/* Hamburger Btn */
.hamburger {
    display: none;
    /* hidden on desktop */
    font-size: 1.5rem;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    margin-right: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.role-badge {
    background-color: var(--primary);
    color: var(--primary-text);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.close-modal:hover {
    color: var(--danger);
}

/* Notifications */
.notif-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notif-item.warning {
    border-left: 4px solid var(--warning);
    background: #FFFBEB;
}

.notif-item.danger {
    border-left: 4px solid var(--danger);
    background: #FFF5F5;
}

.notif-item.orange {
    border-left: 4px solid var(--secondary);
    background: #FFFAF0;
}

/* Dashboard Activity Stream */
.activity-list {
    list-style: none;
    padding: 0;
}

.activity-item {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    border-left: 4px solid var(--border-color); /* Fallback */
    transition: background 0.2s;
}

.activity-item:hover {
    background: rgba(0,0,0,0.02);
}

.activity-item.exchange { border-left-color: #3b82f6; }
.activity-item.pharmacy { border-left-color: #10b981; }
.activity-item.construction { border-left-color: #f59e0b; }

.activity-time {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.activity-desc {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
}

.notif-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.logout-btn:hover {
    background: var(--danger);
    color: white;
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    color: var(--primary);
}

/* Content Area */
.content-wrapper {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
}

/* Responsive Grid / Cards */
.card {
    background-color: var(--bg-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

/* Grid Layout for Forms/Lists */
.grid-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1024px) {
    .grid-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        /* Hide sidebar */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
        /* Show sidebar */
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .hamburger {
        display: block;
    }

    .topbar {
        padding: 0 1rem;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        /* Stack cards */
    }

    .four-col {
        grid-template-columns: 1fr;
    }

    .grid-layout {
        grid-template-columns: 1fr;
    }

    /* Hide username on small screens? */
    #displayUsername {
        display: none;
    }
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.form-control,
input,
select {
    width: 100%;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-main);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.form-control:focus,
input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.25);
}

/* Button Styles */
.btn-primary {
    background: var(--gradient-primary);
    color: var(--primary-text);
    /* Contrast text */
    font-weight: 700;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: transform 0.1s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}

.full-width {
    width: 100%;
}

/* Utility */
.hidden {
    display: none !important;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.data-table th {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-exchange { background: #e0e7ff; color: #4338ca; }
.badge-pharmacy { background: #dcfce7; color: #15803d; }
.badge-construction { background: #fef9c3; color: #854d0e; }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    /* Fix overflow */
    overflow-y: auto;
    /* Scrollable */
    position: relative;
    box-shadow: var(--shadow-lg);
}

/* Expired Row Highlight */
.expired-warning {
    background-color: #FFF5F5 !important;
    /* Light Red */
    border-left: 4px solid var(--danger);
}

.expired-warning td {
    color: #C53030;
    font-weight: 500;
}

/* Close Modal */
.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* --- UI Utilities (Toasts & Loaders) --- */

/* Toast Container */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Toast Message */
.toast-message {
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    border-left: 5px solid #ccc;
}

.toast-message.show {
    transform: translateX(0);
}

.toast-message.success { border-left-color: var(--success); }
.toast-message.error { border-left-color: var(--danger); }
.toast-message.warning { border-left-color: var(--warning); }
.toast-message.info { border-left-color: var(--info); }

.toast-icon { font-size: 1.2rem; }
.toast-text { color: var(--text-main); font-weight: 500; font-size: 0.95rem; flex: 1; }
.toast-close { cursor: pointer; color: var(--text-muted); font-size: 1.2rem; transition: color 0.2s; }
.toast-close:hover { color: var(--text-main); }

/* Loader */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    border-radius: inherit;
    backdrop-filter: blur(1px);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}
