:root {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #334155;
    --glow: rgba(59, 130, 246, 0.5);
}

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

body {
    font-family: 'Cairo', 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

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

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--bg-card);
    border-left: 1px solid var(--border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: fixed;
    height: 100vh;
    right: 0;
    top: 0;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 20px var(--glow);
}

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

/* Sidebar Nav */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    text-align: right;
}

.nav-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s;
}

.nav-btn:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-main);
}

.nav-btn.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.nav-btn.active svg {
    transform: scale(1.1);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

.filter-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

input[type="text"], input[type="date"], input[type="number"], input[type="time"], select {
    width: 100%;
    padding: 0.8rem 1rem;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    appearance: none; /* For select elements */
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Toggle Checkbox Button */
.hidden-checkbox {
    display: none;
}

.toggle-btn-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    line-height: 1.6;
}

.hidden-checkbox:checked + .toggle-btn-label {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.5);
    color: var(--success);
}

.hidden-checkbox + .toggle-btn-label::before {
    content: "لا (إيقاف)";
}

.hidden-checkbox:checked + .toggle-btn-label::before {
    content: "نعم (يُخصم)";
}

/* Custom dropdown arrow for select */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    background-size: 1.2rem;
    padding-left: 2.5rem;
}

.search-container {
    position: relative;
}

.suggestions-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 20;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5);
}

.suggestion-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: var(--bg-card-hover);
}

.suggestion-name {
    font-weight: 600;
    display: block;
}

.suggestion-no {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.selected-employee {
    margin-top: 0.5rem;
    padding: 0.8rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.selected-employee .emp-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.selected-employee .emp-no {
    font-size: 0.8rem;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

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

.primary-btn {
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--primary);
}

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

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-msg {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    padding: 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Main Content */
.main-content {
    margin-right: 320px;
    flex: 1;
    padding: 2.5rem;
    width: calc(100% - 320px);
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.top-header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(to left, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.25rem;
}

.date-display {
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    border-color: rgba(255,255,255,0.1);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 28px;
    height: 28px;
    color: white;
}

.bg-emerald { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 0 15px rgba(16, 185, 129, 0.3); }
.bg-rose { background: linear-gradient(135deg, #f43f5e, #e11d48); box-shadow: 0 0 15px rgba(244, 63, 94, 0.3); }
.bg-amber { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 0 15px rgba(245, 158, 11, 0.3); }
.bg-indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 0 15px rgba(99, 102, 241, 0.3); }

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

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 0.25rem;
}

/* Table Section */
.table-section {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.table-header h2 {
    font-size: 1.25rem;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

th {
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem 1.5rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.5px;
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

tbody tr {
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: rgba(255,255,255,0.02);
}

.status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status-present {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-absent {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-late {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-holiday {
    background: rgba(99, 102, 241, 0.1);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.status-leave {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(56, 189, 248, 0.15));
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.4);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
    font-weight: bold;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.empty-state-content svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.hidden {
    display: none !important;
}

/* Utilities */
.text-danger { color: #f87171; }
.text-success { color: #34d399; }
.text-muted { color: var(--text-muted); }

/* Table Actions */
.action-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.view {
    transition: opacity 0.3s ease;
}

.view.hidden {
    display: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    .main-content {
        margin-right: 280px;
        width: calc(100% - 280px);
    }
}

.filter-btn { background: transparent; border: 1px solid rgba(255, 255, 255, 0.1); color: var(--text-secondary); padding: 0.4rem 1rem; border-radius: 20px; font-size: 0.85rem; cursor: pointer; transition: all 0.3s ease; }
.filter-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.filter-btn.active { background: rgba(99, 102, 241, 0.2); border-color: rgba(99, 102, 241, 0.5); color: #818cf8; }

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
    }
    
    .sidebar {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        border-left: none !important;
        border-bottom: 1px solid var(--border);
        padding: 1.5rem 1rem 1rem 1rem !important;
        z-index: 10;
        box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    }

    .filter-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.8rem;
    }

    .filter-group {
        margin-bottom: 0 !important;
        margin-top: 0 !important;
    }

    /* Target specific filter groups to span full width or hide hrs */
    .filter-group:has(#employeeCheckList),
    .filter-group:has(select),
    .filter-section > div:has(button) {
        grid-column: 1 / -1;
    }

    hr {
        display: none;
    }
    
    .main-content {
        margin-right: 0 !important;
        width: 100% !important;
        padding: 1rem 0.5rem !important;
    }
    
    .top-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.8rem;
        padding: 0 1rem;
    }
    
    .top-header h1 {
        font-size: 1.5rem;
    }

    .header-actions {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    /* Make Sidebar navigation scrollable horizontally */
    .sidebar-nav {
        flex-direction: row !important;
        overflow-x: auto !important;
        padding: 0 0 0.5rem 0 !important;
        gap: 0.5rem !important;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    .sidebar-nav::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    .nav-btn {
        flex-shrink: 0;
        padding: 0.6rem 1.2rem !important;
        font-size: 0.9rem !important;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 20px;
    }
    
    .nav-btn.active {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
    }
    
    .nav-btn svg {
        display: none; /* Hide icons on mobile tabs to save space */
    }
    
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.5rem !important;
        padding: 0 !important;
        margin: 0 0 1.5rem 0 !important;
    }
    
    .stat-card {
        padding: 0.8rem 0.4rem !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        gap: 0.4rem !important;
    }
    
    .stat-details {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .stat-label {
        font-size: 0.7rem !important;
        white-space: normal !important;
        line-height: 1.2 !important;
    }

    .stat-value {
        font-size: 1.1rem !important;
        margin-top: 0.1rem !important;
    }
    
    .stat-icon {
        width: 32px !important;
        height: 32px !important;
        border-radius: 8px !important;
        margin-bottom: 0.2rem !important;
    }
    
    .stat-icon svg {
        width: 16px !important;
        height: 16px !important;
    }
    
    .sidebar-footer {
        display: none !important;
    }
    
    .mobile-footer {
        display: block !important;
        text-align: center;
        padding: 1.5rem;
        color: var(--text-muted);
        font-size: 0.8rem;
    }
    
    .table-section {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .table-header {
        padding: 1rem;
        text-align: center;
    }
    
    th, td {
        padding: 0.8rem 0.5rem !important;
        font-size: 0.85rem !important;
        white-space: nowrap;
    }
}

/* For very small phones */
@media (max-width: 480px) {
    .stat-card {
        flex: 0 0 110px !important;
    }
}
.mobile-footer { display: none; }
