/* ==========================================================================
   BOXFARMA ITAÚNA - SISTEMA DE DISPENSAÇÃO E VALIDAÇÃO DE RECEITAS
   DESIGN SYSTEM & MODERN LAYOUT STYLING (PREMIUM LIGHT THEME ONLY)
   ========================================================================== */

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

:root {
    /* Color Palette - Default Light Theme */
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8fafc;
    --glass-bg: #ffffff;
    --glass-border: #e2e8f0;
    
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-glow: rgba(2, 132, 199, 0.08);
    --secondary: #4f46e5;
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.1);
    --warning: #d97706;
    --warning-glow: rgba(217, 119, 6, 0.1);
    --danger: #dc2626;
    --danger-glow: rgba(220, 38, 38, 0.1);
    --info: #2563eb;
    --info-glow: rgba(37, 99, 235, 0.1);

    /* Text Colors */
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dark: #94a3b8;

    /* Spacing & Borders */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 30px;
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    
    /* Shadows */
    --shadow-main: 0 4px 20px 0 rgba(148, 163, 184, 0.08);
    --shadow-glow: 0 0 15px rgba(2, 132, 199, 0.1);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(2, 132, 199, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
    transition: background-color var(--transition-smooth), color var(--transition-fast);
}

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

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.main-content {
    flex: 1;
    padding: 2.5rem;
    margin-left: 280px; /* Sidebar Width */
    transition: margin-left var(--transition-smooth);
    width: 100%;
}

/* Off-canvas behavior when sidebar is collapsed */
.app-container.sidebar-collapsed .main-content {
    margin-left: 80px;
}

/* ==========================================================================
   SIDEBAR COMPONENT (MATCHING PAINT LAYOUT)
   ========================================================================== */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--glass-border);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.25rem 1.5rem;
    transition: width var(--transition-smooth), padding var(--transition-smooth);
    box-shadow: 4px 0 24px rgba(148, 163, 184, 0.05);
}

/* Minimized view for sidebar collapse */
.app-container.sidebar-collapsed .sidebar {
    width: 80px;
    padding: 2rem 0.5rem 1.5rem;
    overflow: visible !important;
}

/* Hiding brand logo and text labels when sidebar is collapsed */
.app-container.sidebar-collapsed .brand,
.app-container.sidebar-collapsed .brand-name,
.app-container.sidebar-collapsed .nav-label,
.app-container.sidebar-collapsed .sidebar-section-title,
.app-container.sidebar-collapsed .profile-details,
.app-container.sidebar-collapsed .profile-logout,
.app-container.sidebar-collapsed .sidebar-close-btn span {
    display: none !important;
}

.app-container.sidebar-collapsed .sidebar-header {
    justify-content: center;
}

.app-container.sidebar-collapsed .sidebar-close-btn {
    align-self: center;
}

.app-container.sidebar-collapsed .nav-item a {
    justify-content: center;
    padding: 0.8rem 0;
}

.app-container.sidebar-collapsed .sidebar-profile-box {
    justify-content: center;
    padding: 0.5rem;
    background: transparent;
    border-color: transparent;
}

/* Top bar: Brand logo and hamburger to close sidebar */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.15rem;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}

.brand-name {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--text-main) 30%, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.sidebar-close-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.sidebar-close-btn i {
    font-size: 1.25rem;
}

.sidebar-close-btn span {
    font-size: 0.62rem;
    text-transform: lowercase;
    font-weight: 600;
    margin-top: 0.15rem;
    white-space: nowrap;
    color: var(--text-dark);
}

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

.sidebar-close-btn:hover span {
    color: var(--danger);
}

/* Sidebar dividers matching paint lines */
.sidebar-divider {
    height: 1px;
    background-color: var(--glass-border);
    margin: 1.25rem 0;
    border: none;
}

/* Gestão Section Header */
.sidebar-section-title {
    font-size: 0.8rem;
    text-transform: lowercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

/* Navigation Items */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1.1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.92rem;
    border: 1px solid var(--glass-border);
    background: var(--bg-tertiary);
}

.nav-item a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-dark);
}

.nav-item.active a {
    background: var(--primary-glow);
    color: var(--primary);
    border-color: rgba(2, 132, 199, 0.2);
}

.nav-item.active a i {
    color: var(--primary);
}

.nav-item a:hover {
    color: var(--text-main);
    border-color: var(--text-dark);
    background: var(--bg-primary);
}

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

/* Bottom Profile Box matching paint layout */
.sidebar-profile-box {
    margin-top: auto;
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    gap: 0.75rem;
    overflow: hidden;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}

.profile-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.profile-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.profile-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.profile-logout {
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.profile-logout:hover {
    color: #b91c1c;
    text-decoration: underline;
}

/* ==========================================================================
   HEADER COMPONENT (WITH FLOATING HAMBURGER WHEN CLOSED)
   ========================================================================== */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    padding: 1.2rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.page-title p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.header-left-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Floating hamburger reopen button - Only visible when menu is closed */
.hamburger-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-size: 1.15rem;
    cursor: pointer;
    display: none; /* Hidden by default when sidebar is open */
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    box-shadow: var(--shadow-main);
}

.app-container.sidebar-collapsed .hamburger-btn {
    display: flex; /* Display when collapsed */
}

.hamburger-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
    transform: scale(1.05);
}

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */
.glass-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-main);
    transition: transform var(--transition-smooth), border-color var(--transition-fast);
}

.glass-card:hover {
    border-color: rgba(2, 132, 199, 0.15);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

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

/* ==========================================================================
   INPUTS & FORM ELEMENTS
   ========================================================================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

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

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1.25rem;
    color: var(--text-dark);
    font-size: 1.05rem;
    pointer-events: none;
    transition: var(--transition-fast);
}

.input-field {
    width: 100%;
    padding: 0.9rem 1.25rem 0.9rem 3.2rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.input-field::placeholder {
    color: var(--text-dark);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-secondary);
    box-shadow: 0 0 12px rgba(2, 132, 199, 0.1);
}

.input-field:focus + .input-icon {
    color: var(--primary);
}

/* CEP Autocomplete Pulser styling */
.cep-loading {
    animation: pulse 1.5s infinite ease-in-out;
    border-color: var(--primary) !important;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.9rem 1.75rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    border: none;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.15);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.25);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--text-dark);
    color: var(--text-main);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.25);
}

.btn-block {
    width: 100%;
}

/* ==========================================================================
   STATUS BADGES
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-xl);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-success {
    background: var(--success-glow);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.15);
}
.badge-success .badge-dot { background: var(--success); }

.badge-warning {
    background: var(--warning-glow);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.15);
}
.badge-warning .badge-dot { background: var(--warning); }

.badge-danger {
    background: var(--danger-glow);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.15);
}
.badge-danger .badge-dot { background: var(--danger); }

.badge-info {
    background: var(--info-glow);
    color: #1e3a8a;
    border: 1px solid rgba(59, 130, 246, 0.15);
}
.badge-info .badge-dot { background: var(--info); }

/* ==========================================================================
   PRESCRIPTION VALIDATION COMPONENT
   ========================================================================== */
.receipt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
}

.receipt-code-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-dark);
    font-weight: 700;
    letter-spacing: 1px;
}

.receipt-code {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.meta-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
}

.meta-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

.meta-value {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}

.meta-subvalue {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Medications List */
.meds-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.meds-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.med-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-fast);
}

.med-card:hover {
    border-color: var(--text-dark);
}

.med-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.med-name {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.92rem;
}

.med-dosage {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.med-qty {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
}

/* ==========================================================================
   ALERTS & FEEDBACK
   ========================================================================== */
.alert {
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid transparent;
    font-size: 0.88rem;
    line-height: 1.4;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.alert-danger {
    background: var(--danger-glow);
    border-color: rgba(220, 38, 38, 0.15);
    color: #b91c1c;
}

.alert-success {
    background: var(--success-glow);
    border-color: rgba(16, 185, 129, 0.15);
    color: #065f46;
}

.alert-warning {
    background: var(--warning-glow);
    border-color: rgba(217, 119, 6, 0.15);
    color: #92400e;
}

.alert-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

/* ==========================================================================
   ANIMATIONS & TRANSITIONS
   ========================================================================== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.scale-up {
    animation: scaleUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.empty-state-icon {
    width: 70px;
    height: 70px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    transition: var(--transition-smooth);
}

.empty-state:hover .empty-state-icon {
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
    transform: translateY(-3px);
}

.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 320px;
    line-height: 1.5;
}

.quick-hint {
    background: var(--primary-glow);
    border: 1px dashed rgba(2, 132, 199, 0.3);
    padding: 0.75rem 1.1rem;
    border-radius: var(--radius-md);
    margin-top: 1.25rem;
    font-size: 0.78rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ==========================================================================
   SUCCESS FULLSCREEN CELEBRATION
   ========================================================================== */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(241, 245, 249, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.25s ease forwards;
}

.success-modal-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-lg);
    padding: 3rem;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(148, 163, 184, 0.12);
    animation: scaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.success-check-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--success-glow);
    border: 2px solid var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: var(--success);
    margin: 0 auto 1.5rem;
}

.success-modal-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.success-modal-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.75rem;
}

/* ==========================================================================
   BREADCRUMB & MODAL TRANSITIONS
   ========================================================================== */
.header-bar.breadcrumb-mode {
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    min-height: auto;
}

/* When breadcrumb mode is active, align breadcrumb and title to the left */
.header-bar.breadcrumb-mode .header-left-actions {
    align-items: flex-start;
}
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease forwards;
}

.modal-overlay.active {
    display: flex;
}

/* ==========================================================================
   USER PROFILE DROPDOWN COMPONENT
   ========================================================================== */
.sidebar-profile-box {
    position: relative; /* Base anchor */
}

.profile-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(148, 163, 184, 0.15), 0 8px 10px -6px rgba(148, 163, 184, 0.15);
    min-width: 180px;
    padding: 0.75rem;
    z-index: 1200;
    text-align: left;
    pointer-events: auto;
}

.profile-dropdown.active {
    display: block;
    animation: slideUpFade 0.2s ease forwards;
}

.profile-dropdown .dropdown-item:hover {
    background: rgba(239, 68, 68, 0.06) !important;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translate(-50%, 8px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE ADAPTATION)
   ========================================================================== */
@media (max-width: 768px) {
    /* Main container adapts to vertical stacking */
    .app-container {
        flex-direction: column;
    }

    .main-content {
        margin-left: 0 !important;
        margin-top: 60px; /* Leave space for the top navbar */
        padding: 1.5rem 1rem !important;
        min-height: calc(100vh - 60px);
    }

    /* 1. COLLAPSED (MINIMIZED) STATE ON MOBILE - BECOMES TOP NAVBAR */
    .app-container.sidebar-collapsed .sidebar {
        width: 100% !important;
        height: 60px !important;
        flex-direction: row-reverse !important; /* Puts hamburger on the right, profile badge on the left */
        align-items: center !important;
        justify-content: space-between !important;
        padding: 0 1.25rem !important;
        border-right: none !important;
        border-bottom: 1px solid var(--glass-border) !important;
        box-shadow: 0 4px 20px rgba(148, 163, 184, 0.05) !important;
        z-index: 9999 !important; /* Floating above breadcrumbs/all contents */
        overflow: visible !important; /* Enable dropdown output rendering */
    }

    /* Hide navigation menu entirely in mobile collapsed mode */
    .app-container.sidebar-collapsed .sidebar-nav {
        display: none !important;
    }

    /* Adjust header inside collapsed sidebar/navbar */
    .app-container.sidebar-collapsed .sidebar-header {
        margin-bottom: 0 !important;
        width: auto !important;
        justify-content: flex-end !important;
        overflow: visible !important;
    }

    .app-container.sidebar-collapsed .sidebar-close-btn {
        align-self: center !important;
    }

    /* Hide divider in collapsed navbar */
    .app-container.sidebar-collapsed .sidebar-divider {
        display: none !important;
    }

    /* Align avatar badge on mobile navbar left side */
    .app-container.sidebar-collapsed .sidebar-profile-box {
        margin-top: 0 !important;
        margin-left: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        overflow: visible !important; /* Enable dropdown output rendering */
    }

    /* Mobile profile dropdown adjustments to open downwards */
    .app-container.sidebar-collapsed .profile-dropdown {
        bottom: auto !important;
        top: calc(100% + 10px) !important;
        left: 0 !important;
        transform: none !important;
        animation: slideDownFadeMobile 0.2s ease forwards !important;
    }

    /* 2. OPENED STATE ON MOBILE - OCCUPIES WHOLE SCREEN OVERLAY */
    .sidebar {
        width: 100% !important;
        height: 100vh !important;
        padding: 1.5rem 1.5rem !important;
        z-index: 1100 !important;
    }

    /* Brand stays next to hamburger when expanded */
    .sidebar-header {
        margin-bottom: 2rem !important;
        overflow: visible !important;
    }

    /* Make profile box a standard flex display on bottom */
    .sidebar-profile-box {
        padding: 1rem !important;
        background: var(--bg-tertiary) !important;
        border: 1px solid var(--glass-border) !important;
    }

    /* Hide footer margins */
    .app-footer {
        margin-top: 2rem !important;
    }
}

@keyframes slideDownFadeMobile {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

