@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&display=swap');

:root {
    /* Modern Light Palette: "Clean Day" */
    --bg-main: #f1f5f9;      /* Slate 100 */
    --bg-card: #ffffff;      /* White */
    --sidebar-bg: #ffffff;   /* White */
    
    --accent: #4f46e5;       /* Indigo 600 */
    --accent-hover: #4338ca; /* Indigo 700 */
    --secondary: #0ea5e9;    /* Sky 500 */
    
    --text-primary: #1e293b; /* Slate 800 */
    --text-secondary: #64748b; /* Slate 500 */
    
    --border: #e2e8f0;       /* Slate 200 */
    
    --success: #10b981;
    --danger: #ef4444;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Dark Mode Overrides */
body.dark-mode {
    --bg-main: #0f172a;       /* Dark Blue */
    --bg-card: #1e293b;       /* Slate 800 */
    --sidebar-bg: #0f172a;    
    
    --text-primary: #f8fafc;  /* White/Light Gray */
    --text-secondary: #94a3b8;
    
    --border: #334155;        /* Slate 700 */
    
    --shadow-sm: none;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Modern Scrollbar */
::-webkit-scrollbar {
    width: 8px; /* Slightly wider for better visibility */
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent); /* Change to accent color on hover */
}

/* Specific Dark Mode Tweaks */
body.dark-mode .nav-item:hover {
    background: #1e293b;
    color: var(--secondary);
}
body.dark-mode select, body.dark-mode input {
    background: #1e293b;
    color: white;
}
body.dark-mode th {
    background: #1e293b;
    color: var(--text-secondary);
}
body.dark-mode tr:hover td {
    background: #1e293b;
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: 100vh;
    max-height: 100vh;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    position: fixed;
    right: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    overflow: hidden; /* Hide overflow on parent, children will handle it */
    transition: width 0.3s;
}

.sidebar-links {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

/* Custom Scrollbar for Sidebar specifically */
.sidebar-links::-webkit-scrollbar {
    width: 5px;
}
.sidebar-links::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 50px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.brand i {
    color: var(--accent);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
    font-weight: 600;
}

.nav-item:hover {
    background: #f8fafc;
    color: var(--accent);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.nav-item i { width: 25px; transition: 0.3s; }
.nav-item:hover i { transform: scale(1.1); }

/* Main Content */
.main {
    margin-right: 280px;
    padding: 40px;
    transition: 0.3s;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    background: var(--bg-card);
    padding: 24px 30px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.title h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}
.title p { color: var(--text-secondary); margin-top: 5px; }

/* Cards & Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover { 
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-label { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 10px; font-weight: 600; }
.stat-value { font-size: 2.5rem; font-weight: 700; color: var(--text-primary); }

/* Tables */
.table-container { 
    overflow-x: auto; 
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: right;
    padding: 18px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    text-transform: uppercase;
    background: #f8fafc;
}

td {
    padding: 18px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
    font-weight: 500;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: 0.2s;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 10px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}
.btn-secondary:hover { 
    background: #f8fafc; 
    border-color: var(--text-secondary);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 8px;
    border-radius: 8px;
    transition: 0.2s;
}
.btn-icon:hover { background: #f1f5f9; color: var(--accent); }

/* Status Badges */
.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 8px;
}
.online { background: var(--success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }

/* Animations */
.animate-enter { animation: fadeInUp 0.4s ease-out forwards; opacity: 0; }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Elements */
input, select {
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text-primary); /* Dark Text */
    padding: 12px;
    border-radius: 8px;
    outline: none;
    transition: 0.2s;
    width: 100%;
}
input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Fix for Select Arrow in Light Mode */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%231e293b%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: left 12px top 50%;
    background-size: 10px auto;
}

/* Modal Overlay */
#modal, #editModal {
    background: rgba(0,0,0,0.5) !important; /* Dimmed background */
}

/* Footer Styling - Compact Bar */
.footer {
    margin-top: 60px;
    padding: 15px 30px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.15);
    color: white;
    margin-bottom: 20px;
    max-width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    font-weight: 600;
    font-size: 0.95rem;
}

.footer-text, .footer-badge {
    color: white !important;
}

.footer-separator {
    opacity: 0.6;
}

.footer-copy {
    display: none; /* Removed for compact bar style */
}

/* Sidebar Profile Styling Improvements */
.sidebar .user-profile {
    transition: 0.3s;
    border-radius: 16px;
    margin: 10px;
    background: rgba(79, 70, 229, 0.03);
}

body.dark-mode .sidebar .user-profile {
    background: rgba(255, 255, 255, 0.03);
}

/* Responsive Main Content */
@media (max-width: 1024px) {
    .sidebar { width: 85px; padding: 25px 10px; }
    .sidebar .brand span, .sidebar .nav-item span, .sidebar .user-profile div { display: none; }
    .sidebar .brand, .sidebar .nav-item { justify-content: center; padding: 18px; }
    .main { margin-right: 85px; }
}

@media (max-width: 768px) {
    .sidebar { 
        right: -100%; 
        display: flex; /* Override display:none */
        transition: right 0.3s ease;
    }
    .sidebar.active {
        right: 0;
    }
    .main { margin-right: 0; padding: 20px; }
    
    .mobile-nav-toggle {
        display: block !important;
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 1001;
        background: var(--accent);
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 8px;
        box-shadow: var(--shadow-md);
        cursor: pointer;
    }
}

.mobile-nav-toggle { display: none; }

/* Professional Print Styles */
@media print {
    @page {
        size: A4;
        margin: 1.5cm;
    }

    body {
        background: white !important;
        color: black !important;
        min-height: auto;
    }

    .sidebar, .actions, .filter-bar, .footer, #themeToggle, button, .btn-primary, .btn-secondary, #syncOverlay {
        display: none !important;
    }

    .main {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        background: transparent !important;
        margin-bottom: 20px;
    }

    .header {
        border-bottom: 2px solid #000 !important;
        padding-bottom: 10px !important;
        margin-bottom: 30px !important;
        background: transparent !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .title h1 {
        font-size: 24pt !important;
        color: black !important;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 10pt !important;
    }

    th {
        background: #f0f0f0 !important;
        color: black !important;
        border: 1px solid #ddd !important;
        padding: 8px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    td {
        border: 1px solid #ddd !important;
        padding: 8px !important;
        color: black !important;
    }

    .badge {
        border: 1px solid #000 !important;
        background: transparent !important;
        color: black !important;
        padding: 2px 5px !important;
    }

    /* Progress bar for print */
    .print-progress {
        width: 100% !important;
        height: 10px !important;
        border: 1px solid #000 !important;
        background: #eee !important;
    }
}

.print-only {
    display: none !important;
}
