/* 
 * Rawaa ERP System — Design System
 * Programmed by Mohamed Wael
 * Day Mode / Light Theme — Vanilla CSS
 */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-base: hsl(210, 30%, 96%);
    --bg-surface: hsl(0, 0%, 100%);
    --bg-surface-elevated: hsl(210, 25%, 98%);
    --bg-glass: rgba(255,255,255,0.85);
    --border-glass: rgba(0,0,0,0.08);
    --primary: hsl(201, 100%, 40%);
    --primary-hover: hsl(201, 100%, 32%);
    --primary-glow: hsla(201, 100%, 40%, 0.08);
    --primary-light: hsl(201, 100%, 95%);
    --secondary: hsl(265, 80%, 55%);
    --secondary-glow: hsla(265, 80%, 55%, 0.08);
    --success: hsl(142, 75%, 35%);
    --success-glow: hsla(142, 75%, 35%, 0.08);
    --success-light: hsl(142, 75%, 93%);
    --warning: hsl(38, 95%, 40%);
    --warning-light: hsl(38, 95%, 93%);
    --danger: hsl(346, 85%, 45%);
    --danger-light: hsl(346, 85%, 93%);
    --text-primary: hsl(222, 25%, 12%);
    --text-secondary: hsl(222, 15%, 35%);
    --text-muted: hsl(222, 10%, 55%);
    --border-color: hsl(220, 15%, 90%);
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --font-en: 'Outfit', sans-serif;
    --font-ar: 'Cairo', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

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

body {
    background: var(--bg-base);
    background-image: radial-gradient(at 0% 0%, hsla(201,100%,40%,0.03) 0px, transparent 50%), radial-gradient(at 100% 100%, hsla(265,80%,55%,0.03) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

html[dir="ltr"] { font-family: var(--font-en); }
html[dir="rtl"] { font-family: var(--font-ar); }
a { color: inherit; text-decoration: none; transition: var(--transition); }

/* Layout */
.app-container { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0;
    width: var(--sidebar-width); background: var(--bg-surface);
    border-inline-end: 1px solid var(--border-color);
    display: flex; flex-direction: column; z-index: 100;
    box-shadow: var(--shadow-sm); transition: var(--transition);
    overflow-y: auto;
}
.main-content {
    flex: 1; margin-inline-start: var(--sidebar-width);
    min-height: 100vh; display: flex; flex-direction: column;
    transition: var(--transition);
}
.content-body { padding: 20px; flex: 1; }

/* Brand */
.brand { padding: 16px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border-color); }
.brand-logo {
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.1rem;
}
.brand-name { font-weight: 700; font-size: 1.15rem; color: var(--text-primary); }

/* Nav */
.nav-menu { list-style: none; padding: 12px 8px; flex: 1; }
.nav-item { margin-bottom: 2px; }
.nav-item a {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    border-radius: var(--radius-sm); color: var(--text-secondary);
    font-weight: 500; font-size: 0.9rem; transition: var(--transition);
}
.nav-item a:hover { background: var(--primary-glow); color: var(--primary); }
.nav-item.active a { background: var(--primary-glow); color: var(--primary); font-weight: 600; }
.nav-item a i { font-size: 1.2rem; }

/* Sidebar Footer */
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border-color); }
.user-profile { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }
.logout-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 6px; border-radius: 6px; transition: var(--transition); }
.logout-btn:hover { color: var(--danger); background: var(--danger-light); }

/* Header */
.header {
    height: var(--header-height); display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px; background: var(--bg-surface); border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 50;
}
.page-title h1 { font-size: 1.2rem; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.lang-switch-btn {
    padding: 6px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: transparent; cursor: pointer; font-size: 0.85rem; font-weight: 500;
    color: var(--text-secondary); transition: var(--transition); display: inline-flex; align-items: center; gap: 4px;
}
.lang-switch-btn:hover { background: var(--primary-glow); color: var(--primary); border-color: var(--primary); }

/* Footer */
.footer { text-align: center; padding: 14px; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border-color); }

/* Cards */
.card { background: var(--bg-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); overflow: hidden; transition: var(--transition); }
.card:hover { box-shadow: var(--shadow-md); }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border-color); font-weight: 600; display: flex; justify-content: space-between; align-items: center; font-size: 0.95rem; }
.card-body { padding: 18px; }

/* Stat Cards */
.stat-card { background: var(--bg-surface); border-radius: var(--radius-md); padding: 18px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); display: flex; align-items: center; gap: 16px; transition: var(--transition); }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.purple { background: hsla(265,80%,55%,0.1); color: var(--secondary); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* Tables */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 10px 14px; background: var(--bg-surface-elevated); font-weight: 600;
    text-align: start; border-bottom: 2px solid var(--border-color);
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary);
    white-space: nowrap;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; font-size: 0.9rem; }
.data-table tbody tr:hover { background: var(--primary-glow); }
.data-table .summary-row { background: var(--bg-surface-elevated); font-weight: 700; border-top: 2px solid var(--primary); }

/* Buttons */
.btn {
    padding: 8px 18px; border-radius: var(--radius-sm); font-weight: 600;
    cursor: pointer; transition: var(--transition); border: none;
    display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem;
    text-decoration: none; line-height: 1.4;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-glow); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-icon { padding: 6px; border-radius: 50%; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; }
.btn-ghost { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); }
.btn-ghost:hover { color: var(--primary); background: var(--primary-glow); }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 0.85rem; color: var(--text-secondary); }
.form-control {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); font-size: 0.9rem; transition: var(--transition);
    outline: none; background: var(--bg-surface); color: var(--text-primary);
    font-family: inherit;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-inline-end: 32px; }
html[dir="rtl"] select.form-control { background-position: left 12px center; padding-inline-end: 12px; padding-inline-start: 32px; }
textarea.form-control { min-height: 70px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-text { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; }
.is-invalid { border-color: var(--danger) !important; }
.invalid-feedback { color: var(--danger); font-size: 0.8rem; margin-top: 3px; }

/* Modals */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px); padding: 20px;
}
.modal {
    background: var(--bg-surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 620px;
    max-height: 90vh; overflow-y: auto; animation: slideUp 0.25s ease;
}
.modal-lg { max-width: 900px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); font-weight: 700; font-size: 1.05rem; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }

/* Badges */
.badge { padding: 3px 10px; border-radius: 50px; font-size: 0.72rem; font-weight: 600; display: inline-block; }
.badge-draft { background: var(--warning-light); color: var(--warning); }
.badge-posted { background: var(--success-light); color: var(--success); }
.badge-void { background: var(--danger-light); color: var(--danger); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--danger-light); color: var(--danger); }
.badge-approved { background: var(--primary-light); color: var(--primary); }
.badge-planned { background: hsla(265,80%,55%,0.1); color: var(--secondary); }
.badge-in_progress { background: var(--primary-light); color: var(--primary); }
.badge-completed { background: var(--success-light); color: var(--success); }
.badge-cancelled { background: var(--danger-light); color: var(--danger); }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border-color); gap: 0; overflow-x: auto; }
.tab {
    padding: 10px 20px; cursor: pointer; font-weight: 500; color: var(--text-muted);
    border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition);
    white-space: nowrap; font-size: 0.9rem; background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content { display: none; padding: 16px 0; }
.tab-content.active { display: block; }

/* Tree View */
.tree-item { padding: 8px 14px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 8px; font-size: 0.9rem; transition: var(--transition); }
.tree-item:hover { background: var(--primary-glow); }
.tree-item.header-account { font-weight: 600; background: var(--bg-surface-elevated); }
.tree-indent { display: inline-block; }

/* File Upload */
.file-upload-zone {
    border: 2px dashed var(--border-color); border-radius: var(--radius-md);
    padding: 30px; text-align: center; transition: var(--transition); cursor: pointer;
}
.file-upload-zone:hover, .file-upload-zone.dragover { border-color: var(--primary); background: var(--primary-glow); }
.file-upload-zone i { font-size: 2.5rem; color: var(--text-muted); margin-bottom: 8px; display: block; }
.file-list { list-style: none; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-bottom: 6px; }
.file-item .file-icon { font-size: 1.4rem; color: var(--primary); }
.file-item .file-info { flex: 1; }
.file-item .file-name { font-weight: 500; font-size: 0.9rem; }
.file-item .file-meta { font-size: 0.75rem; color: var(--text-muted); }

/* Calendar Grid */
.calendar-grid { display: grid; gap: 3px; }
.calendar-cell {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    border-radius: 4px; font-size: 0.7rem; font-weight: 600; cursor: pointer; transition: var(--transition);
    border: 1px solid transparent; min-width: 28px; min-height: 28px;
}
.calendar-cell:hover { border-color: var(--primary); }
.cell-present { background: var(--success-light); color: var(--success); }
.cell-absent { background: var(--danger-light); color: var(--danger); }
.cell-excuse { background: var(--warning-light); color: var(--warning); }
.cell-leave { background: var(--primary-light); color: var(--primary); }
.cell-empty { background: var(--bg-surface-elevated); color: var(--text-muted); }

/* Empty State */
.empty-state { text-align: center; padding: 50px 20px; }
.empty-state i { font-size: 3.5rem; color: var(--text-muted); margin-bottom: 12px; display: block; }
.empty-state p { color: var(--text-secondary); font-size: 1rem; }

/* Toast */
.toast {
    position: fixed; bottom: 24px; inset-inline-end: 24px; z-index: 10000;
    background: var(--bg-surface); border: 2px solid var(--primary);
    padding: 12px 20px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 10px; animation: slideUp 0.3s ease;
}

/* Action Bar */
.action-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.search-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.search-input { min-width: 200px; }

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* Profile */
.profile-header { display: flex; gap: 20px; align-items: center; padding: 20px; }
.profile-photo { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid white; box-shadow: var(--shadow-md); }
.profile-photo-placeholder { width: 100px; height: 100px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; font-weight: 700; }
.profile-info h2 { font-size: 1.3rem; margin-bottom: 4px; }
.profile-meta { color: var(--text-muted); font-size: 0.85rem; }

/* Login */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, hsl(201,100%,95%), hsl(265,80%,95%)); padding: 20px; }
.login-card { background: var(--bg-surface); border-radius: var(--radius-lg); padding: 36px; box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .brand-logo { width: 56px; height: 56px; font-size: 1.5rem; margin: 0 auto 10px; border-radius: 14px; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; }
.login-logo p { color: var(--text-muted); font-size: 0.85rem; }

/* Report Sections */
.report-section { margin-bottom: 20px; }
.report-section-title { font-size: 0.95rem; font-weight: 700; padding: 10px 14px; background: var(--bg-surface-elevated); border-radius: var(--radius-sm); margin-bottom: 8px; color: var(--text-primary); }

/* Utilities */
.flex { display: flex; } .flex-between { justify-content: space-between; } .flex-center { align-items: center; }
.gap-sm { gap: 8px; } .gap-md { gap: 16px; } .gap-lg { gap: 24px; }
.text-center { text-align: center; } .text-end { text-align: end; } .text-start { text-align: start; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-primary { color: var(--primary); } .text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 700; } .fw-600 { font-weight: 600; }
.fs-sm { font-size: 0.8rem; } .fs-lg { font-size: 1.1rem; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.p-2 { padding: 8px; } .p-3 { padding: 16px; } .p-4 { padding: 24px; }
.w-100 { width: 100%; }
.d-none { display: none; }
.cursor-pointer { cursor: pointer; }
.overflow-auto { overflow: auto; }
.nowrap { white-space: nowrap; }

/* Animations */
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
[x-cloak] { display: none !important; }

/* Print */
@media print {
    .sidebar, .header, .footer, .action-bar, .btn, .toast, .modal-overlay { display: none !important; }
    .main-content { margin: 0 !important; }
    .content-body { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* Responsive */
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    html[dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-inline-start: 0 !important; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .modal { max-width: 95%; }
    .profile-header { flex-direction: column; text-align: center; }
    .action-bar { flex-direction: column; align-items: stretch; }
}
