/* CSS Variables & Theme */
:root {
    /* Colors */
    --primary-color: #2c3e50;
    /* Midnight Blue - Sidebar/Text */
    --secondary-color: #34495e;
    /* Wet Asphalt - Navigation */
    --accent-color: #3498db;
    /* Peter River - Primary Actions */
    --accent-hover: #2980b9;
    --success-color: #27ae60;
    /* Nephritis - Success Actions */
    --warning-color: #f39c12;
    /* Orange - Alerts */
    --danger-color: #e74c3c;
    /* Alizarin - Errors */
    --light-bg: #f5f6fa;
    /* Ghost White - Main Background */
    --white: #ffffff;
    --text-color: #2d3436;
    --text-muted: #636e72;
    --border-color: #dfe6e9;

    /* Dimensions */
    --sidebar-width: 260px;
    --header-height: 70px;

    /* Effects */
    --card-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    --card-hover-shadow: 0 15px 45px rgba(0, 0, 0, 0.08);
    --transition-speed: 0.3s;
    --radius: 20px;
    --radius-lg: 28px;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* HIDDEN BY DEFAULT */
    transform: translateX(-100%);
    inset-inline-start: 0;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
}

.sidebar.active {
    transform: translateX(0);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-speed);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding-inline: 25px;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding-block: 20px;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: #bdc3c7;
    font-weight: 500;
    transition: all var(--transition-speed);
    text-decoration: none;
    border-inline-start: 4px solid transparent;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--white);
    border-inline-start-color: var(--accent-color);
}

.nav-link i {
    width: 24px;
    text-align: center;
    margin-inline-end: 12px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Main Content */
.main-content {
    flex: 1;
    /* NO LONGER PUSHED BY DEFAULT */
    margin-inline-start: 0;
    padding: 30px;
    transition: margin-inline-start 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

.sidebar.active~.main-content {
    margin-inline-start: var(--sidebar-width);
}

@media screen and (max-width: 768px) {
    .sidebar.active~.main-content {
        margin-inline-start: 0;
    }

    /* Swipe area hint or interaction area */
    .sidebar::after {
        content: '';
        position: absolute;
        right: -40px;
        top: 0;
        bottom: 0;
        width: 40px;
        background: transparent;
    }
}

/* Top Bar */
.top-bar {
    background: var(--white);
    height: var(--header-height);
    padding-inline: 30px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--card-shadow);
    margin-bottom: 30px;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.page-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

/* Hamburger Menu (Mobile) */
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
    width: 45px;
    height: 45px;
    border-radius: 12px;
    font-size: 1.2rem;
    cursor: pointer;
    margin-inline-end: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    transition: all 0.2s;
}

.menu-toggle:hover {
    background: #f8fafc;
    transform: scale(1.05);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
    margin-bottom: 25px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow var(--transition-speed);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-hover-shadow);
}

/* Grids */
.grid-2-col,
.grid-3-col,
.grid-4-col {
    display: grid;
    gap: 25px;
    margin-bottom: 25px;
}

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

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

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

/* Stats Cards */
.stat-card {
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-inline-end: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-info .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 5px;
}

.stat-info .stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.85rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th {
    background-color: #f8f9fa;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 15px 20px;
    text-align: inherit;
    /* Inherit align from RTL/LTR */
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: #fcfcfc;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.9rem;
    transition: all 0.2s;
    background-color: #fcfcfc;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    gap: 8px;
    font-size: 0.9rem;
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

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

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

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    /* top/right/bottom/left */
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--white);
    padding: 30px;
    border-radius: 16px;
    width: 500px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-overlay.open .modal-content {
    transform: scale(1);
}

/* Premium Modal Layouts */
.modal-content-premium {
    background: white;
    border-radius: 24px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-overlay.open .modal-content-premium {
    transform: scale(1);
}

.modal-header-premium {
    padding: 25px 35px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body-premium {
    padding: 35px;
}

.modal-footer-premium {
    padding: 20px 35px;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    border-top: 1px solid #f1f5f9;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.premium-input-group {
    margin-bottom: 20px;
}

.premium-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.premium-input {
    width: 100%;
    height: 48px;
    border-radius: 12px;
    border: 2px solid #f1f5f9;
    padding: 0 15px;
    font-size: 0.95rem;
    transition: all 0.3s;
    background: #f8fafc;
}

.premium-input:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    outline: none;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
    .grid-4-col {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 768px) {

    /* Layout */
    .sidebar {
        transform: translateX(calc(var(--sidebar-width) * -1));
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    }

    /* RTL Sidebar Hidden State */
    [dir="rtl"] .sidebar {
        transform: translateX(var(--sidebar-width));
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-footer {
        padding-bottom: 90px;
        /* 70px for bottom nav + 20px buffer */
    }

    .main-content {
        margin-inline-start: 0;
        padding: 15px;
    }

    /* Grids */
    .grid-4-col,
    .grid-3-col,
    .grid-2-col {
        grid-template-columns: 1fr;
    }

    /* Top Bar */
    .top-bar {
        padding-inline: 15px;
    }

    .menu-toggle {
        display: block;
    }

    /* PREMIUM MOBILE APP STYLES */
    body {
        padding-bottom: 90px;
        /* Increased for floating nav */
    }

    .main-content {
        padding: 16px;
    }

    .top-bar {
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(25px);
        margin-bottom: 16px;
        border: 1px solid rgba(255, 255, 255, 0.5);
        border-radius: 20px;
        position: sticky;
        top: env(safe-area-inset-top, 10px);
        z-index: 900;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        /* Center Title */
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
    }

    .page-title {
        font-size: 1rem !important;
        font-weight: 800;
        letter-spacing: -0.3px;
    }

    .menu-toggle {
        position: absolute;
        left: 15px;
    }

    /* Glass Cards for Mobile */
    .card {
        padding: 20px;
        border-radius: var(--radius-lg);
        background: var(--white);
        border: 1px solid rgba(0, 0, 0, 0.04);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    }

    /* Bottom Navigation - Floating Native Style */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 12px;
        left: 12px;
        right: 12px;
        height: 65px;
        background: rgba(44, 62, 80, 0.85);
        /* Midnight Glass */
        backdrop-filter: blur(20px) saturate(180%);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 24px;
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        padding-bottom: 0;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: rgba(255, 255, 255, 0.5);
        text-decoration: none;
        font-size: 10px;
        font-weight: 700;
        gap: 2px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        flex: 1;
        position: relative;
    }

    .bottom-nav-item i {
        font-size: 18px;
        margin-bottom: 2px;
    }

    .bottom-nav-item.active {
        color: var(--white);
    }

    .bottom-nav-item.active::before {
        content: '';
        position: absolute;
        top: -12px;
        width: 30px;
        height: 4px;
        background: var(--accent-color);
        border-radius: 0 0 10px 10px;
        box-shadow: 0 4px 10px rgba(52, 152, 219, 0.5);
    }

    .bottom-nav-item.active {
        color: var(--accent-color);
    }

    .bottom-nav-item.active i {
        transform: translateY(-2px);
    }

    /* Mobile Data List (Table Alternative) */
    .mobile-data-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .mobile-data-card {
        background: var(--white);
        border-radius: 20px;
        padding: 16px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
        border: 1px solid rgba(0, 0, 0, 0.04);
        transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    }

    .mobile-data-card:active {
        transform: scale(0.96);
    }

    .mobile-data-info h4 {
        font-size: 15px;
        font-weight: 700;
        margin-bottom: 4px;
        color: var(--primary-color);
    }

    .mobile-data-info p {
        font-size: 11px;
        color: var(--text-muted);
        font-weight: 500;
    }

    .mobile-data-value {
        text-align: right;
        font-weight: 700;
        color: var(--primary-color);
    }

    /* Responsive Table Hider */
    .desktop-only-table {
        display: none;
    }

    /* Full Screen Modal on Mobile */
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        border-radius: 0;
        margin: 0;
        padding-top: 60px;
        /* Space for close button */
        overflow-y: auto;
    }

    .modal-close-btn {
        position: absolute;
        top: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        background: #f0f2f5;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
    }

    /* Standardize card padding and font sizes for mobile */
    /* The .card rule above replaces this one for mobile */
    /* .card {
        padding: 15px;
        border-radius: 12px;
    } */

    .page-title {
        font-size: 1.1rem;
    }

    .stat-info .stat-value {
        font-size: 1.4rem;
    }

    /* Ensure tables don't break layout */
    .table-container {
        margin: 0 -15px;
        width: calc(100% + 30px);
        padding: 0 15px;
    }

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

/* Tablet Optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .grid-4-col {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .sidebar.active~.main-content {
        margin-inline-start: var(--sidebar-width);
    }
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-20 {
    margin-bottom: 20px;
}

.gap-10 {
    gap: 10px;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

/* =========================================
   Professional Login Page Styles
   ========================================= */

.login-body {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    /* Deep Blue Gradient */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    position: relative;
    overflow: hidden;
}

/* Background Pattern Overlay (Optional Polish) */
.login-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.login-card:hover {
    transform: translateY(-5px);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-icon {
    font-size: 3.5rem;
    color: #2a5298;
    background: rgba(42, 82, 152, 0.1);
    width: 90px;
    height: 90px;
    line-height: 90px;
    border-radius: 50%;
    margin: 0 auto 1.5rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(42, 82, 152, 0.15);
}

.login-header h2 {
    color: #1e3c72;
    font-weight: 700;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.login-header p {
    color: #7f8c8d;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Login Form Inputs */
.login-card .form-group {
    margin-bottom: 1.5rem;
}

.login-card .form-label {
    font-size: 0.9rem;
    color: #576574;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

.login-card .input-group {
    position: relative;
    transition: all 0.3s;
}

.login-card .input-group i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #bdc3c7;
    font-size: 1.1rem;
    transition: color 0.3s;
    z-index: 2;
}

.login-card .form-control {
    padding-left: 48px;
    height: 50px;
    background: #f8f9fa;
    border: 2px solid #eef2f7;
    border-radius: 10px;
    font-size: 1rem;
    color: #2c3e50;
    transition: all 0.3s;
}

.login-card .form-control:focus {
    background: #fff;
    border-color: #2a5298;
    box-shadow: 0 0 0 4px rgba(42, 82, 152, 0.1);
}

.login-card .form-control:focus+i,
.login-card .input-group:focus-within i {
    color: #2a5298;
}

/* Login Button */
.login-card .btn-primary {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border: none;
    height: 54px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 10px;
    margin-top: 1rem;
    box-shadow: 0 8px 20px rgba(42, 82, 152, 0.25);
    transition: all 0.3s;
}

.login-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(42, 82, 152, 0.35);
    filter: brightness(1.1);
}

.login-card .btn-primary:active {
    transform: translateY(0);
}

/* Footer Text */
.login-card .text-light {
    color: #95a5a6;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Shake Animation (kept from previous logic, ensured here) */
/* Sidebar Close Button (Mobile Only) */
.sidebar-close {
    display: none;
    position: absolute;
    top: 15px;
    right: -50px;
    /* Positioned at the edge */
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 12px 12px 0;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    transition: all 0.3s;
}

[dir="rtl"] .sidebar-close {
    right: auto;
    left: -50px;
    border-radius: 12px 0 0 12px;
}

@media (max-width: 768px) {
    .sidebar.active .sidebar-close {
        display: flex;
    }
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    50% {
        transform: translateX(10px);
    }

    75% {
        transform: translateX(-10px);
    }

    100% {
        transform: translateX(0);
    }
}
