/* ============================================
   MOBILE DESIGN - Inspired by Modern UI
   Dark theme with mobile-first approach
   ============================================ */

/* Mobile-specific root variables */
:root {
    --mobile-nav-height: 70px;
    --mobile-header-height: 60px;
    --mobile-fab-size: 56px;
    --mobile-card-radius: 12px;
    --mobile-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    --mobile-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.25);
    --mobile-accent: #4a00ff;
    --mobile-accent-dark: #3600cc;
}

/* Dark theme colors */
[data-theme="dark"] {
    --mobile-bg-primary: #1E1E1E;
    --mobile-bg-secondary: #2D2D2D;
    --mobile-bg-card: #2D2D2D;
    --mobile-text-primary: #E8E8E8;
    --mobile-text-secondary: #A0A0A0;
    --mobile-border: #404040;
}

/* Light theme colors */
[data-theme="light"] {
    --mobile-bg-primary: #F5F5F5;
    --mobile-bg-secondary: #FFFFFF;
    --mobile-bg-card: #FFFFFF;
    --mobile-text-primary: #202124;
    --mobile-text-secondary: #5F6368;
    --mobile-border: #E0E0E0;
}

/* ============================================
   HAMBURGER MENU BUTTON (ALL SCREENS)
   ============================================ */

/* Hamburger menu button - visible on all screens */
.mobile-menu-btn {
    width: 40px;
    height: 40px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0 12px 0 0;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
}

.mobile-menu-btn:hover {
    background-color: rgba(128, 128, 128, 0.15);
    border-radius: 8px;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    position: relative;
    transition: all 0.3s ease;
    margin: 0;
}

/* Dark theme colors */
[data-theme="dark"] .mobile-menu-btn span,
[data-theme="dark"] .mobile-menu-btn span::before,
[data-theme="dark"] .mobile-menu-btn span::after {
    background-color: #E8E8E8;
}

/* Light theme colors */
[data-theme="light"] .mobile-menu-btn span,
[data-theme="light"] .mobile-menu-btn span::before,
[data-theme="light"] .mobile-menu-btn span::after {
    background-color: #202124;
}

.mobile-menu-btn span::before,
.mobile-menu-btn span::after {
    content: '';
    position: absolute;
    left: 0;
    width: 24px;
    height: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-btn span::before {
    top: -8px;
}

.mobile-menu-btn span::after {
    bottom: -8px;
}

/* Active/Open state */
.mobile-menu-btn.active span {
    background-color: transparent !important;
}

.mobile-menu-btn.active span::before {
    top: 0;
    transform: rotate(45deg);
}

.mobile-menu-btn.active span::after {
    bottom: 0;
    transform: rotate(-45deg);
}

/* ============================================
   MOBILE LAYOUT ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    /* Body adjustments */
    body {
        padding-top: var(--mobile-header-height) !important;
        padding-bottom: calc(var(--mobile-nav-height) + 20px) !important;
        background-color: var(--mobile-bg-primary) !important;
    }

    /* Hide desktop navigation */
    .navbar .menu-horizontal {
        display: none !important;
    }

    /* Mobile Header */
    .navbar {
        height: var(--mobile-header-height) !important;
        min-height: var(--mobile-header-height) !important;
        background-color: var(--mobile-bg-secondary) !important;
        border-bottom: 1px solid var(--mobile-border);
        padding: 0 16px;
    }

    .navbar .flex-1 {
        justify-content: flex-start; /* Align left instead of center */
    }

    /* Mobile search bar */
    .mobile-search-bar {
        position: fixed;
        top: var(--mobile-header-height);
        left: 0;
        right: 0;
        padding: 12px 16px;
        background-color: var(--mobile-bg-secondary);
        border-bottom: 1px solid var(--mobile-border);
        z-index: 40;
    }

    .mobile-search-input {
        width: 100%;
        padding: 12px 16px;
        border-radius: 24px;
        background-color: var(--mobile-bg-primary);
        border: 1px solid var(--mobile-border);
        color: var(--mobile-text-primary);
        font-size: 14px;
    }

    .mobile-search-input::placeholder {
        color: var(--mobile-text-secondary);
    }

    /* Container adjustments */
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
        max-width: 100% !important;
    }

    /* ============================================
       MOBILE CARD DESIGN
       ============================================ */
    
    .mobile-card {
        background-color: var(--mobile-bg-card);
        border-radius: var(--mobile-card-radius);
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: var(--mobile-shadow);
        border: 1px solid var(--mobile-border);
        transition: all 0.2s ease;
    }

    .mobile-card:active {
        transform: scale(0.98);
        box-shadow: var(--mobile-shadow-lg);
    }

    .mobile-card-header {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 12px;
    }

    .mobile-card-icon {
        width: 40px;
        height: 40px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .mobile-card-icon.pdf {
        background-color: rgba(234, 67, 53, 0.15);
        color: #EA4335;
    }

    .mobile-card-icon.excel {
        background-color: rgba(52, 168, 83, 0.15);
        color: #34A853;
    }

    .mobile-card-icon.doc {
        background-color: rgba(66, 133, 244, 0.15);
        color: #4285F4;
    }

    .mobile-card-icon svg {
        width: 24px;
        height: 24px;
    }

    .mobile-card-content {
        flex: 1;
    }

    .mobile-card-title {
        font-size: 14px;
        font-weight: 500;
        color: var(--mobile-text-primary);
        margin-bottom: 4px;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mobile-card-meta {
        font-size: 12px;
        color: var(--mobile-text-secondary);
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    .mobile-card-meta span {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    .mobile-card-actions {
        display: flex;
        gap: 8px;
        align-items: center;
    }

    .mobile-card-action-btn {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--mobile-text-secondary);
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-card-action-btn:active {
        background-color: var(--mobile-bg-primary);
    }

    /* ============================================
       BOTTOM NAVIGATION
       ============================================ */
    
    .mobile-bottom-nav {
        z-index: 1000;
        position: fixed;
        bottom: 16px;
        left: 16px;
        right: 16px;
        height: var(--mobile-nav-height);
        background-color: var(--mobile-bg-secondary); /* Ensure high contrast bg */
        border: 1px solid var(--mobile-border);
        border-radius: 24px;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 8px;
        z-index: 50;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
        backdrop-filter: blur(10px);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end; /* Align bottom to keep labels aligned */
        gap: 4px;
        padding: 8px 12px;
        color: #000000;
        text-decoration: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        cursor: pointer;
        min-width: 64px;
        height: 56px; /* Fixed height for alignment */
        border-radius: 16px;
        position: relative;
        overflow: hidden;
        background: transparent;
        border: none;
    }

    .mobile-nav-item::before {
        content: '';
        position: absolute;
        inset: 0;
        background-color: var(--mobile-accent);
        opacity: 0;
        transition: opacity 0.3s ease;
        border-radius: 16px;
    }

    .mobile-nav-item:hover::before {
        opacity: 0.1;
    }

    .mobile-nav-item.active {
        color: #FFFFFF; /* Force white text for contrast on active pill */
        background-color: var(--mobile-accent);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(74, 0, 255, 0.6), 0 2px 8px rgba(0, 0, 0, 0.15);
        border: 2px solid rgba(255, 255, 255, 0.2);
    }

    .mobile-nav-item.active svg,
    .mobile-nav-item.active span {
        opacity: 1 !important; /* Full opacity for active item */
    }

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

    .mobile-nav-icon {
        width: 24px;
        height: 24px;
        transition: transform 0.3s ease;
    }

    .mobile-nav-item:hover .mobile-nav-icon {
        transform: scale(1.1);
    }

    .mobile-nav-item.active .mobile-nav-icon {
        transform: scale(1);
    }


    .mobile-nav-label {
        font-size: 12px;
        font-weight: 600;
        text-align: center;
        white-space: nowrap;
    }

    /* ============================================
       FLOATING ACTION BUTTON (FAB)
       ============================================ */
    
    .mobile-fab {
        position: fixed;
        bottom: calc(var(--mobile-nav-height) + 16px);
        right: 16px;
        width: var(--mobile-fab-size);
        height: var(--mobile-fab-size);
        border-radius: 16px;
        background: linear-gradient(135deg, var(--mobile-accent) 0%, var(--mobile-accent-dark) 100%);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(66, 133, 244, 0.4);
        cursor: pointer;
        border: none;
        z-index: 45;
        transition: all 0.3s ease;
    }

    .mobile-fab:active {
        transform: scale(0.9);
    }

    .mobile-fab svg {
        width: 28px;
        height: 28px;
    }

    .mobile-fab-label {
        position: absolute;
        right: calc(var(--mobile-fab-size) + 12px);
        background-color: var(--mobile-bg-card);
        color: var(--mobile-text-primary);
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 14px;
        font-weight: 500;
        white-space: nowrap;
        box-shadow: var(--mobile-shadow);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .mobile-fab:hover .mobile-fab-label {
        opacity: 1;
    }

    /* ============================================
   MOBILE DRAWER MENU (Desktop Only)
   ============================================ */

.mobile-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background-color: var(--mobile-bg-secondary);
    box-shadow: var(--mobile-shadow-lg);
    z-index: 60;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.mobile-drawer.active {
    left: 0;
}

.mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-drawer-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.mobile-drawer-header {
    padding: 24px 16px;
    border-bottom: 1px solid var(--mobile-border);
}

.mobile-drawer-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.mobile-drawer-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--mobile-accent) 0%, var(--mobile-accent-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
}

.mobile-drawer-user-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--mobile-text-primary);
    margin: 0;
}

.mobile-drawer-user-info p {
    font-size: 12px;
    color: var(--mobile-text-secondary);
    margin: 0;
}

.mobile-drawer-menu {
    padding: 8px 0;
}

.mobile-drawer-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    color: var(--mobile-text-primary);
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.mobile-drawer-item:hover {
    background-color: var(--mobile-bg-primary);
}

.mobile-drawer-item:active {
    background-color: var(--mobile-bg-primary);
}

.mobile-drawer-item svg {
    width: 24px;
    height: 24px;
    color: var(--mobile-text-secondary);
}

.mobile-drawer-item span {
    font-size: 14px;
    font-weight: 500;
}

/* Mobile Drawer: slide in from left on demand */
@media (max-width: 768px) {
    .mobile-drawer {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: -280px !important;
        width: 280px !important;
        height: 100vh !important;
        background-color: var(--mobile-bg-secondary) !important;
        visibility: hidden; /* Changed from display: none to allow transitions */
        opacity: 0;
        transform: translateX(-100%); /* Add transform for better performance */
        transition: transform 0.3s ease-in-out, opacity 0.3s linear, visibility 0s linear 0.3s !important;
        z-index: 9999 !important;
    }

    .mobile-drawer.active {
        left: 0 !important;
        transform: translateX(0) !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important; /* Ensure clicks work */
        transition: transform 0.3s ease-in-out, opacity 0.3s linear, visibility 0s linear 0s !important;
    }

    .mobile-drawer-overlay {
        display: block !important;
        z-index: 90 !important;
    }

    .mobile-drawer-overlay.active {
        opacity: 1 !important;
        pointer-events: all !important;
    }
}

    /* ============================================
       MOBILE TABLE ADJUSTMENTS
       ============================================ */
    
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        border-radius: var(--mobile-card-radius);
        box-shadow: var(--mobile-shadow);
    }

    table thead {
        display: none;
    }

    table tbody {
        display: block;
    }

    table tr {
        display: flex;
        flex-direction: column;
        background-color: var(--mobile-bg-card);
        border-radius: var(--mobile-card-radius);
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid var(--mobile-border);
    }

    table td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border: none;
    }

    table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--mobile-text-secondary);
        font-size: 12px;
        text-transform: uppercase;
    }

    /* ============================================
       MOBILE FORM ADJUSTMENTS
       ============================================ */
    
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px 16px !important;
        border-radius: 8px !important;
    }

    .btn {
        padding: 12px 24px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
        min-height: 44px !important; /* Better touch target */
    }

    /* ============================================
       MOBILE BADGE & CHIPS
       ============================================ */
    
    .mobile-badge {
        display: inline-flex;
        align-items: center;
        padding: 4px 12px;
        border-radius: 16px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .mobile-badge.success {
        background-color: rgba(52, 168, 83, 0.15);
        color: #34A853;
    }

    .mobile-badge.warning {
        background-color: rgba(251, 188, 5, 0.15);
        color: #FBBC05;
    }

    .mobile-badge.error {
        background-color: rgba(234, 67, 53, 0.15);
        color: #EA4335;
    }

    .mobile-badge.info {
        background-color: rgba(66, 133, 244, 0.15);
        color: #4285F4;
    }

    /* ============================================
       MOBILE SECTION HEADERS
       ============================================ */
    
    .mobile-section-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 8px 12px 8px;
        margin-top: 8px;
    }

    .mobile-section-title {
        font-size: 16px;
        font-weight: 600;
        color: var(--mobile-text-primary);
    }

    .mobile-section-action {
        font-size: 14px;
        color: var(--mobile-accent);
        text-decoration: none;
        font-weight: 500;
    }

    /* ============================================
       MOBILE QUICK ACTIONS
       ============================================ */
    
    .mobile-quick-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 12px;
        margin-bottom: 24px;
    }

    .mobile-quick-action {
        background-color: var(--mobile-bg-card);
        border-radius: var(--mobile-card-radius);
        padding: 16px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        text-decoration: none;
        border: 1px solid var(--mobile-border);
        transition: all 0.2s ease;
    }

    .mobile-quick-action:active {
        transform: scale(0.95);
    }

    .mobile-quick-action-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, var(--mobile-accent) 0%, var(--mobile-accent-dark) 100%);
        color: white;
    }

    .mobile-quick-action-label {
        font-size: 12px;
        font-weight: 500;
        color: var(--mobile-text-primary);
        text-align: center;
    }

    /* ============================================
       MOBILE ANIMATIONS
       ============================================ */
    
    @keyframes slideUp {
        from {
            transform: translateY(20px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .mobile-card,
    .mobile-quick-action {
        animation: slideUp 0.3s ease forwards;
    }

    /* Stagger animation for multiple cards */
    .mobile-card:nth-child(1) { animation-delay: 0.05s; }
    .mobile-card:nth-child(2) { animation-delay: 0.1s; }
    .mobile-card:nth-child(3) { animation-delay: 0.15s; }
    .mobile-card:nth-child(4) { animation-delay: 0.2s; }
    .mobile-card:nth-child(5) { animation-delay: 0.25s; }

    /* ============================================
       MOBILE LOADING STATES
       ============================================ */
    
    .mobile-skeleton {
        background: linear-gradient(90deg, var(--mobile-bg-primary) 25%, var(--mobile-bg-card) 50%, var(--mobile-bg-primary) 75%);
        background-size: 200% 100%;
        animation: shimmer 1.5s infinite;
        border-radius: 4px;
    }

    @keyframes shimmer {
        0% {
            background-position: 200% 0;
        }
        100% {
            background-position: -200% 0;
        }
    }

    /* ============================================
       MOBILE MODALS & DIALOGS
       ============================================ */
    
    .modal-box {
        max-width: calc(100vw - 32px) !important;
        margin: 16px !important;
        border-radius: var(--mobile-card-radius) !important;
    }

    /* ============================================
       UTILITY CLASSES
       ============================================ */
    
    .hide-on-mobile {
        display: none !important;
    }

    .show-on-mobile {
        display: block !important;
    }

    /* ============================================
       DARK THEME MOBILE NAVBAR COLORS
       ============================================ */
    
    [data-theme="dark"] .mobile-nav-item {
        color: #E8E8E8 !important;
    }

    [data-theme="dark"] .mobile-nav-item svg {
        color: #E8E8E8 !important;
    }

    [data-theme="dark"] .mobile-nav-item span {
        color: #E8E8E8 !important;
    }

    [data-theme="dark"] .mobile-nav-item.active {
        color: #FFFFFF !important;
    }

    [data-theme="dark"] .mobile-nav-item.active svg {
        color: #FFFFFF !important;
    }

    [data-theme="dark"] .mobile-nav-item.active span {
        color: #FFFFFF !important;
    }

    [data-theme="dark"] .mobile-bottom-nav {
        background: rgba(30, 30, 30, 0.95) !important;
        border-color: rgba(100, 100, 100, 0.5) !important;
    }
}

/* ============================================
   DESKTOP: Hide mobile-only elements & Permanent Sidebar
   ============================================ */

@media (min-width: 769px) {
    .mobile-bottom-nav,
    .mobile-fab,
    .mobile-search-bar {
        display: none !important;
    }

    /* Permanent sidebar on desktop */
    .mobile-drawer {
        display: block !important;
        left: 0 !important;
        top: 56px;
        height: calc(100vh - 56px);
        transition: none;
        box-shadow: none;
        border-right: 1px solid var(--mobile-border);
    }

    /* Hide overlay on desktop (not needed for permanent sidebar) */
    .mobile-drawer-overlay {
        display: none !important;
    }

    /* Hide hamburger buttons on desktop */
    .mobile-menu-btn {
        display: none !important;
    }

    /* Adjust content for sidebar */
    .container {
        margin-left: 280px !important;
        max-width: calc(100% - 280px) !important;
    }

    /* Adjust navbar for sidebar */
    .navbar {
        left: 280px !important;
        width: calc(100% - 280px) !important;
    }

    .hide-on-desktop {
        display: none !important;
    }
}
