/* ==========================================
   1. CSS VARIABLES (Modern SaaS Theme)
   ========================================== */
:root {
    --brand-orange: #F05a24;
    --brand-orange-hover: #d1491b;
    --brand-dark: #1e293b; /* Softer black */
    --brand-gray-dark: #404040;
    --brand-gray-med: #595959;
    --bg-light: #f8fafc; /* Very soft blue/gray for backgrounds */
    --bg-white: #ffffff;
    --border-light: #e2e8f0;
    --text-muted: #64748b;
}

/* ==========================================
   2. GLOBAL RESET & TYPOGRAPHY
   ========================================== */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Inter', -apple-system, sans-serif; 
}

body { 
    background-color: var(--bg-light); 
    color: var(--brand-dark); 
    -webkit-font-smoothing: antialiased;
}

/* Visibility */
.screen { display: none; }
.screen.active { display: flex; }

/* ==========================================
   3. LOGIN SCREEN
   ========================================== */
#login-screen, #forgot-screen, #set-password-screen { 
    height: 100vh; 
    justify-content: center; 
    align-items: center; 
    background-color: var(--bg-light);
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
}
.login-card { 
    background: var(--bg-white); 
    padding: 40px; 
    border-radius: 16px; 
    text-align: center; 
    width: 100%; 
    max-width: 420px; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    border: 1px solid var(--border-light);
}
.login-card .logo { max-width: 220px; margin-bottom: 30px; }
.login-card h2 { margin-bottom: 8px; color: var(--brand-dark); font-size: 24px; font-weight: 700; letter-spacing: -0.5px;}
.login-card p { margin-bottom: 30px; color: var(--text-muted); font-size: 15px; }

/* ==========================================
   4. LAYOUT: SIDEBAR & TOPBAR
   ========================================== */
.layout { height: 100vh; width: 100vw; overflow: hidden; }

.sidebar { 
    width: 280px; 
    background-color: var(--brand-gray-dark); 
    display: flex; 
    flex-direction: column; 
    color: var(--bg-white); 
}
.sidebar-header { 
    padding: 24px; 
    background-color: rgba(0,0,0,0.2); 
    display: flex; 
    justify-content: center; 
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-header img { max-width: 160px; border-radius: 8px; }

.nav-links { list-style: none; padding: 20px 0; flex: 1; }
.nav-links li { 
    padding: 12px 24px; 
    cursor: pointer; 
    color: #cbd5e1; 
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease; 
    border-left: 3px solid transparent; 
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-links li i { font-size: 18px; opacity: 0.7; }
.nav-links li:hover { 
    background-color: rgba(255,255,255,0.05); 
    color: var(--bg-white); 
}
.nav-links li.active { 
    background-color: rgba(240, 90, 36, 0.1); 
    color: var(--brand-orange); 
    border-left-color: var(--brand-orange); 
}
.nav-links li.active i { opacity: 1; }

.main-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.topbar { 
    background-color: var(--bg-white); 
    padding: 20px 30px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid var(--border-light);
    z-index: 10;
}
.topbar h1 { font-size: 20px; font-weight: 600; color: var(--brand-dark); letter-spacing: -0.5px;}

.content-area { padding: 30px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ==========================================
   5. BUTTONS (Sleek & Interactive)
   ========================================== */
button { 
    display: inline-flex; 
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 18px; 
    margin-bottom: 10px; 
    border: none; 
    border-radius: 6px;
    font-weight: 600; 
    font-size: 14px;
    cursor: pointer; 
    transition: all 0.2s ease; 
}
.btn-primary { 
    background-color: var(--brand-orange); 
    color: var(--bg-white); 
    box-shadow: 0 2px 4px rgba(240, 90, 36, 0.2);
}
.btn-primary:hover:not(:disabled) { 
    background-color: var(--brand-orange-hover); 
    transform: translateY(-1px); 
    box-shadow: 0 4px 10px rgba(240, 90, 36, 0.3); 
}
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary { 
    background-color: var(--bg-white); 
    color: var(--brand-dark); 
    border: 1px solid var(--border-light); 
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.btn-secondary:hover:not(:disabled) { 
    background-color: #f1f5f9; 
    border-color: #cbd5e1;
}

.btn-logout { 
    background-color: transparent; 
    color: #94a3b8; 
    border: 1px solid rgba(255,255,255,0.1); 
}
.btn-logout:hover { 
    background-color: rgba(255,255,255,0.05); 
    color: var(--bg-white); 
}

/* ==========================================
   6. CARDS & DATA BOXES
   ========================================== */
.grid-cards { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 20px; 
    margin-bottom: 30px; 
}
.card { 
    background: var(--bg-white); 
    padding: 24px; 
    border-radius: 12px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
    border: 1px solid var(--border-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}
.card.orange { border-top: 4px solid var(--brand-orange); }
.card h3 { color: var(--text-muted); font-size: 13px; font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;}
.card .value { font-size: 32px; font-weight: 700; color: var(--brand-dark); letter-spacing: -1px;}

.data-box { 
    background: var(--bg-white); 
    padding: 30px; 
    border-radius: 12px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
    border: 1px solid var(--border-light);
    margin-bottom: 25px; 
}
.data-box h2 { 
    margin-bottom: 8px; 
    color: var(--brand-dark); 
    font-size: 20px; 
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* ==========================================
   7. MODERN FORMS & INPUTS
   ========================================== */
.form-section { 
    background: #f8fafc; 
    padding: 24px; 
    border-radius: 8px; 
    margin-bottom: 20px; 
    border: 1px dashed #cbd5e1; 
}
.form-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
    gap: 16px; 
    margin-bottom: 16px; 
}
.form-group { margin-bottom: 16px; }
.form-group label { 
    display: block; 
    margin-bottom: 6px; 
    font-size: 12px; 
    font-weight: 600; 
    color: var(--brand-dark); 
}
input[type="text"], input[type="number"], input[type="date"], input[type="password"], select, textarea { 
    width: 100%; 
    padding: 10px 14px; 
    border: 1px solid #cbd5e1; 
    border-radius: 6px; 
    font-size: 14px;
    background: var(--bg-white);
    color: var(--brand-dark);
    transition: all 0.2s ease; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 3px rgba(240, 90, 36, 0.15);
}
.input-group { display: flex; gap: 8px; margin-bottom: 16px; }
.input-group input, .input-group select { flex: 1; margin-bottom: 0; }
.input-group .btn-primary { width: auto; margin-bottom: 0; }
.two-col { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); 
    gap: 24px; 
    align-items: start;
}
/* Ensure tables don't break the two-col layout */
.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.table-container .data-table {
    border: none;
    margin: 0;
}

/* ==========================================
   8. CLEAN TABLES & BADGES
   ========================================== */
.data-table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 15px; 
    font-size: 14px; 
    border-radius: 8px;
    overflow: hidden; 
    border: 1px solid var(--border-light);
}
.data-table th, .data-table td { 
    padding: 14px 20px; 
    text-align: left; 
    border-bottom: 1px solid var(--border-light); 
}
.data-table th { 
    background-color: #f8fafc; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    font-size: 12px; 
    font-weight: 600;
    letter-spacing: 0.5px;
}
.data-table tbody tr { background-color: var(--bg-white); transition: background-color 0.1s; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background-color: #f1f5f9; }

/* Premium Status Badges */
.badge { 
    display: inline-flex;
    align-items: center;
    padding: 4px 10px; 
    border-radius: 9999px; 
    font-size: 11px; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
}
.badge.pass, .badge.resolved { background-color: #dcfce7; color: #166534; }
.badge.fail, .badge.high { background-color: #fee2e2; color: #991b1b; }
.badge.active { background-color: #ffedd5; color: #9a3412; }
.badge.med, .badge[style*="#ffc107"] { background-color: #fef9c3 !important; color: #854d0e !important; }
.badge.low { background-color: #e0f2fe; color: #075985; }

/* ==========================================
   9. MOBILE APP SIMULATOR (Sleeker Device)
   ========================================== */
.mobile-simulator {
    width: 100%;
    max-width: 375px;
    height: 750px;
    background: #f1f5f9;
    border: 14px solid #0f172a;
    border-radius: 40px;
    margin: 0 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    position: relative;
}
/* iPhone notch simulation */
.mobile-simulator::before {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 120px; height: 25px; background: #0f172a;
    border-bottom-left-radius: 15px; border-bottom-right-radius: 15px; z-index: 20;
}
.mobile-header { background: var(--brand-orange); color: white; padding: 35px 15px 15px 15px; text-align: center; font-weight: 600; font-size: 16px; letter-spacing: 0.5px; }
.mobile-content { flex: 1; overflow-y: auto; padding: 15px; background: #f8fafc; }
.mobile-footer { background: var(--bg-white); padding: 15px 20px 25px 20px; border-top: 1px solid var(--border-light); display: flex; gap: 10px; }

.mobile-card { background: var(--bg-white); padding: 16px; border-radius: 12px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid var(--border-light); }
.counter-widget { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; background: #f8fafc; border-radius: 8px; padding: 6px; border: 1px solid var(--border-light);}
.counter-btn { width: 44px; height: 44px; background: var(--bg-white); color: var(--brand-dark); border: 1px solid var(--border-light); border-radius: 6px; font-size: 20px; font-weight: 500; display: flex; align-items: center; justify-content: center;}
.counter-btn.plus { background: var(--brand-orange); color: white; border-color: var(--brand-orange); }
.counter-value { font-size: 20px; font-weight: 600; width: 50px; text-align: center; color: var(--brand-dark); }

/* Mobile Grid Menu Buttons */
.mobile-menu-btn {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 24px 10px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 600;
}
.mobile-menu-btn:active { transform: scale(0.96); background: #f8fafc; }
.mobile-menu-btn i { font-size: 36px; color: var(--brand-orange); }

/* ==========================================
   11. CUSTOM TOGGLE SWITCHES
   ========================================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .3s ease;
    border-radius: 24px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s ease;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
input:checked + .toggle-slider {
    background-color: #ef4444; /* Red for excluded */
}
input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* ==========================================
   12. TOAST NOTIFICATIONS & MODALS
   ========================================== */
#toast-container { 
    position: fixed; 
    top: 20px; 
    right: 20px; 
    z-index: 9999; 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
}
.toast { 
    min-width: 280px; 
    background: var(--bg-white); 
    border-radius: 8px; 
    padding: 16px 20px; 
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); 
    border-left: 4px solid var(--brand-orange); 
    display: flex; 
    align-items: center; 
    animation: slideInRight 0.3s ease-out forwards; 
    font-size: 14px; 
    font-weight: 600; 
    color: var(--brand-dark); 
}
.toast.success { border-left-color: #16a34a; }
.toast.error { border-left-color: #ef4444; }

@keyframes slideInRight { 
    from { transform: translateX(100%); opacity: 0; } 
    to { transform: translateX(0); opacity: 1; } 
}
@keyframes fadeOut { 
    to { opacity: 0; transform: translateY(-10px); } 
}

/* Modal Overlay */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(2px);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
}
.modal-content {
    background: var(--bg-white); width: 100%; max-width: 450px; 
    padding: 30px; border-radius: 12px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

/* ==========================================
   13. RESPONSIVE MOBILE LAYOUT
   ========================================== */

/* Hide the hamburger button by default on Desktop! */
.mobile-menu-toggle { 
    display: none; 
    background: transparent; 
    border: none; 
    font-size: 28px; 
    color: var(--brand-dark); 
    cursor: pointer; 
    padding: 0 15px 0 0; 
    width: auto;
    margin: 0;
}

.sidebar-close-btn { display: none !important; }


@media (max-width: 768px) {
    /* Show the Hamburger only on Mobile! */
    .mobile-menu-toggle { display: block; }
    
    .topbar { padding: 15px; justify-content: flex-start; gap: 10px; }
    .topbar h1 { flex: 1; font-size: 18px; }
    
    .sidebar { position: fixed; left: -280px; top: 0; bottom: 0; z-index: 10000; transition: left 0.3s ease; box-shadow: 4px 0 15px rgba(0,0,0,0); }
    .sidebar.open { left: 0; box-shadow: 4px 0 15px rgba(0,0,0,0.5); }
    
    .content-area { padding: 15px; }
    .grid-cards, .two-col { grid-template-columns: 1fr; gap: 15px; }
    
    .data-box { overflow-x: auto; padding: 15px; }
    .data-table { min-width: 600px; }
    .modal-content { width: calc(100% - 30px); padding: 20px; margin: 15px; max-height: 90vh; overflow-y: auto;}
    .form-grid { grid-template-columns: 1fr; }

    .sidebar-close-btn { 
        display: flex !important; 
        align-items: center; 
        justify-content: center; 
        background: transparent; 
        border: none; 
        color: white; 
        font-size: 24px; 
        cursor: pointer; 
        padding: 0 10px;
    }
}

/* ==========================================
   NATIVE ANDROID APP OVERRIDES
   ========================================== */
body.native-app-mode { background: #f8fafc; overflow: hidden; }
body.native-app-mode .sidebar, 
body.native-app-mode .topbar,
body.native-app-mode .mobile-simulator::before { display: none !important; }

body.native-app-mode .layout { display: block; }
body.native-app-mode .main-content { padding: 0; height: 100vh; width: 100vw; }
body.native-app-mode .content-area { padding: 0; max-width: none; height: 100%; display: flex; flex-direction: column; }

body.native-app-mode .mobile-simulator {
    width: 100vw;
    max-width: 100%;
    height: 100vh;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
}