/* ============================================
   نظام إدارة الموارد البشرية
   التصميم الرئيسي
   ============================================ */

:root {
    --primary: #1e3c72;
    --primary-light: #2a5298;
    --primary-dark: #0f2347;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --border: #dee2e6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);
    --transition: all 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'Tahoma', 'Cairo', 'Arial', sans-serif;
    background: #f0f2f5;
    color: var(--dark);
    line-height: 1.6;
    direction: rtl;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   شاشة تسجيل الدخول
   ============================================ */

.login-body {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-body::before {
    content: '';
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 30px 30px;
    animation: rotate 60s linear infinite;
}

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

.login-container {
    background: #fff;
    padding: 40px 35px;
    border-radius: 24px;
    box-shadow: 0 25px 70px rgba(0,0,0,0.4);
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo {
    font-size: 60px;
    margin-bottom: 12px;
    animation: bounce 2s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.login-header h1 {
    color: var(--primary);
    font-size: 22px;
    margin-bottom: 8px;
    font-weight: 700;
}

.login-header p {
    color: var(--gray);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.password-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.5;
    transition: var(--transition);
}

.toggle-password:hover {
    opacity: 1;
}

.login-footer {
    text-align: center;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--gray);
    font-size: 12px;
}

.login-footer p {
    margin: 4px 0;
}

.login-footer a {
    font-weight: 600;
}

/* ============================================
   النماذج العامة
   ============================================ */

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 13px 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
    background: #fff;
    color: var(--dark);
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-light);
    outline: none;
    box-shadow: 0 0 0 4px rgba(42,82,152,0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--gray);
    font-size: 12px;
}

/* ============================================
   الأزرار
   ============================================ */

.btn {
    display: inline-block;
    padding: 13px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(30,60,114,0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

.btn-secondary {
    background: var(--gray);
    color: #fff;
}

.btn-block {
    width: 100%;
}

/* ============================================
   التنبيهات
   ============================================ */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.6;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-right: 4px solid var(--success);
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border-right: 4px solid var(--danger);
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-right: 4px solid var(--warning);
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-right: 4px solid var(--info);
}

/* ============================================
   شريط التنقل
   ============================================ */

.navbar {
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--primary);
    font-size: 17px;
}

.brand-icon {
    font-size: 24px;
}

.nav-toggle {
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--primary);
    display: none;
    padding: 5px 10px;
    border-radius: 8px;
}

.nav-toggle:active {
    background: var(--light);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
    align-items: center;
}

.nav-menu a {
    padding: 8px 14px;
    border-radius: 8px;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: var(--light);
    color: var(--primary);
    text-decoration: none;
}

.nav-menu .text-danger {
    color: var(--danger);
}

.nav-menu .text-danger:hover {
    background: #fff5f5;
}

/* ============================================
   الحاوية الرئيسية
   ============================================ */

.container {
    max-width: 960px;
    margin: 20px auto;
    padding: 0 15px;
    animation: fadeIn 0.3s ease;
}

/* ============================================
   بطاقة الترحيب
   ============================================ */

.welcome-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    padding: 25px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.welcome-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.welcome-card h2 {
    font-size: 20px;
    margin-bottom: 6px;
    position: relative;
}

.welcome-card p {
    opacity: 0.9;
    font-size: 14px;
    position: relative;
}

.current-time {
    font-size: 28px !important;
    font-weight: 700;
    margin-top: 12px !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

/* ============================================
   أزرار الحضور
   ============================================ */

.attendance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.attendance-btn {
    background: #fff;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 15px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.attendance-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    transition: var(--transition);
}

.attendance-btn.check-in::before {
    background: var(--success);
}

.attendance-btn.check-out::before {
    background: var(--warning);
}

.attendance-btn:hover:not(:disabled) {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(30,60,114,0.15);
}

.attendance-btn.check-in:hover:not(:disabled) {
    border-color: var(--success);
}

.attendance-btn.check-out:hover:not(:disabled) {
    border-color: var(--warning);
}

.attendance-btn .icon {
    font-size: 46px;
    margin-bottom: 10px;
    display: block;
}

.attendance-btn .title {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.attendance-btn .subtitle {
    font-size: 12px;
    color: var(--gray);
    line-height: 1.4;
}

.attendance-btn.done {
    background: #e8f5e9;
    border-color: var(--success);
    cursor: not-allowed;
    opacity: 0.9;
}

.attendance-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.attendance-btn:active:not(:disabled) {
    transform: scale(0.97);
}

/* ============================================
   بطاقات الإحصائيات
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    border-right: 4px solid var(--primary);
    transition: var(--transition);
    cursor: pointer;
    color: inherit;
    text-decoration: none;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.stat-card.warning {
    border-right-color: var(--warning);
}

.stat-card.info {
    border-right-color: var(--info);
}

.stat-card.success {
    border-right-color: var(--success);
}

.stat-card.danger {
    border-right-color: var(--danger);
}

.stat-icon {
    font-size: 34px;
    line-height: 1;
}

.stat-info {
    flex: 1;
}

.stat-info h4 {
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 4px;
    font-weight: 500;
}

.stat-info p {
    font-size: 16px;
    color: var(--primary);
    font-weight: 700;
}

/* ============================================
   التنبيهات المنبثقة (Toast)
   ============================================ */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px;
    max-width: 420px;
    margin: auto;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    background: var(--dark);
    color: #fff;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    transform: translateY(120px);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 9999;
    font-size: 14px;
    font-weight: 500;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.toast-error {
    background: linear-gradient(135deg, #dc3545, #e85d6c);
}

.toast-warning {
    background: linear-gradient(135deg, #ffc107, #ff9800);
    color: #333;
}

.toast-info {
    background: linear-gradient(135deg, #17a2b8, #2ec4d6);
}

/* ============================================
   شاشة التحميل
   ============================================ */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(5px);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
    margin-top: 20px;
    color: var(--primary);
    font-weight: 600;
}

/* ============================================
   الفوتر
   ============================================ */

.footer {
    text-align: center;
    padding: 30px 15px;
    color: var(--gray);
    font-size: 12px;
    margin-top: 40px;
}

.footer p {
    margin: 5px 0;
}

.footer a {
    font-weight: 600;
}

.compliance {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 10px !important;
}

/* ============================================
   زر تثبيت التطبيق
   ============================================ */

.install-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 15px;
    font-family: inherit;
    box-shadow: 0 8px 25px rgba(40,167,69,0.3);
    transition: var(--transition);
}

.install-btn:active {
    transform: scale(0.98);
}

/* ============ سجل الحضور ============ */
.att-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    padding: 22px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.att-header h2 { font-size: 20px; margin-bottom: 5px; }
.att-header p { font-size: 13px; opacity: 0.9; }

.month-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.month-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    transition: var(--transition);
}

.month-btn:hover {
    background: rgba(255,255,255,0.25);
    text-decoration: none;
}

.month-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.month-nav input[type="month"] {
    padding: 10px 15px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    background: rgba(255,255,255,0.95);
    color: var(--primary);
    font-weight: 600;
}

.att-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.att-stat {
    background: #fff;
    padding: 18px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary);
    transition: var(--transition);
}

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

.att-stat.present { border-color: var(--success); }
.att-stat.absent { border-color: var(--danger); }
.att-stat.mission { border-color: #fd7e14; }
.att-stat.leave { border-color: #6f42c1; }
.att-stat.hours { border-color: var(--info); }
.att-stat.late { border-color: var(--warning); }

.att-stat .icon { font-size: 26px; margin-bottom: 5px; }
.att-stat .value { font-size: 24px; font-weight: 700; color: var(--primary); }
.att-stat .label { color: var(--gray); font-size: 12px; margin-top: 4px; }

.att-calendar {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.cal-header, .cal-row {
    display: grid;
    grid-template-columns: 100px 80px 90px 90px 90px 130px 1fr;
    padding: 12px 15px;
    gap: 10px;
    align-items: center;
    font-size: 13px;
}

.cal-header {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 12px;
}

.cal-row {
    border-bottom: 1px solid #f0f0f0;
    transition: var(--transition);
}

.cal-row:hover { background: #f8f9ff; }
.cal-row:last-child { border-bottom: none; }

.cal-row.status-present { background: #f0fdf4; }
.cal-row.status-absent { background: #fef2f2; }
.cal-row.status-mission { background: #fff7ed; }
.cal-row.status-leave { background: #f5f3ff; }
.cal-row.status-weekend { background: #f9fafb; color: #999; }
.cal-row.today { box-shadow: inset 4px 0 0 var(--primary); font-weight: 600; }

.day-name { font-weight: 600; color: var(--primary); }
.date { color: var(--gray); font-size: 12px; }
.time-in, .time-out { font-family: 'Courier New', monospace; font-weight: 600; }
.hours { color: var(--info); font-weight: 600; }

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.status-badge.status-present { background: #d4edda; color: #155724; }
.status-badge.status-absent { background: #f8d7da; color: #721c24; }
.status-badge.status-mission { background: #ffe5b4; color: #9a3412; }
.status-badge.status-leave { background: #ddd6fe; color: #5b21b6; }
.status-badge.status-weekend { background: #e2e3e5; color: #6c757d; }
.location { font-size: 12px; color: var(--gray); }

@media (max-width: 768px) {
    .cal-header { display: none; }
    
    .cal-row {
        grid-template-columns: 1fr 1fr;
        padding: 15px;
        gap: 8px;
    }
    
    .cal-row > span { display: block; }
    .day-name { grid-column: 1; font-size: 15px; }
    .date { grid-column: 2; text-align: left; font-size: 13px; }
    .time-in::before { content: 'حضور: '; color: #888; }
    .time-out::before { content: 'انصراف: '; color: #888; }
    .hours::before { content: 'ساعات: '; color: #888; }
    .status-badge { grid-column: 1 / -1; justify-self: start; }
    .location { grid-column: 1 / -1; font-size: 11px; }
    .att-header { padding: 18px; }
    .att-header h2 { font-size: 17px; }
}

/* ============================================
   الاستجابة للشاشات الصغيرة
   ============================================ */

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        border-radius: 0 0 12px 12px;
    }
    
    .nav-menu.open {
        max-height: 600px;
        padding: 10px;
    }
    
    .nav-menu a {
        padding: 14px 16px;
        border-radius: 8px;
        font-size: 15px;
    }
    
    .attendance-grid {
        grid-template-columns: 1fr;
    }
    
    .login-container {
        padding: 30px 22px;
        border-radius: 20px;
    }
    
    .current-time {
        font-size: 24px !important;
    }
    
    .welcome-card {
        padding: 20px;
    }
    
    .welcome-card h2 {
        font-size: 18px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .toast {
        bottom: 15px;
        right: 15px;
        left: 15px;
    }
}

@media (max-width: 400px) {
    .login-container {
        padding: 25px 18px;
    }
    
    .login-header .logo {
        font-size: 50px;
    }
    
    .login-header h1 {
        font-size: 19px;
    }
    
    .attendance-btn {
        padding: 22px 12px;
    }
    
    .attendance-btn .icon {
        font-size: 38px;
    }
}

/* ============================================
   تحسينات عامة
   ============================================ */

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(42,82,152,0.4);
    outline-offset: 2px;
}

/* ============ صفحة عامة ============ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h2 {
    color: var(--primary);
    font-size: 22px;
}

/* ============ الكارد ============ */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 {
    font-size: 16px;
    color: var(--primary);
    margin: 0;
}

.card-body {
    padding: 22px;
}

.card-body.no-padding {
    padding: 0;
}

/* ============ الجداول ============ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    background: #f8f9fa;
}

.data-table th {
    padding: 12px 15px;
    text-align: right;
    color: #555;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid #e9ecef;
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f8f9ff;
}

.data-table code {
    background: #f0f2f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* ============ Status Pills ============ */
.status-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.status-pill.status-pending { background: #fff3cd; color: #856404; }
.status-pill.status-approved { background: #d4edda; color: #155724; }
.status-pill.status-completed { background: #cfe2ff; color: #084298; }
.status-pill.status-rejected { background: #f8d7da; color: #721c24; }
.status-pill.status-paid { background: #d4edda; color: #155724; }
.status-pill.status-draft { background: #e2e3e5; color: #41464b; }

/* ============ Empty State ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 15px;
}

.empty-state small {
    display: block;
    font-size: 13px;
    opacity: 0.7;
}

/* ============ Modal ============ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #fff;
    border-radius: var(--radius);
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 70px rgba(0,0,0,0.4);
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 20px 22px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 17px;
    color: var(--primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--gray);
    line-height: 1;
    padding: 0 8px;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 22px;
}

.modal-footer {
    padding: 15px 22px;
    background: #f8f9fa;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid #eee;
}

/* ============ Utilities ============ */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--gray) !important; }
.text-center { text-align: center !important; }

.btn-link {
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

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

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header .btn {
        width: 100%;
    }
}

/* ============ Payslip ============ */
.payslip-wrapper {
    max-width: 800px;
    margin: 0 auto;
}

.payslip-print {
    background: #fff;
    padding: 35px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.payslip-header {
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 25px;
}

.payslip-header h1 {
    color: var(--primary);
    font-size: 22px;
    margin-bottom: 6px;
}

.payslip-header h2 {
    color: var(--gray);
    font-size: 16px;
    font-weight: normal;
}

.payslip-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.payslip-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.payslip-table th {
    background: var(--primary);
    color: #fff;
    padding: 12px;
    text-align: right;
    font-size: 14px;
}

.payslip-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

.payslip-table tr:nth-child(even) {
    background: #fafafa;
}

.payslip-table .amount {
    text-align: left;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.payslip-table .deduction { color: var(--danger); }

.payslip-table .section-header td {
    background: #e8ecf6 !important;
    color: var(--primary);
    font-weight: 700;
    padding: 8px 12px;
    font-size: 13px;
}

.payslip-table .total-row {
    background: #f0f2f5 !important;
}

.payslip-table .net-row {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
    color: #fff;
}

.payslip-table .net-row td {
    padding: 15px;
    font-size: 16px;
}

.payslip-footer {
    text-align: center;
    font-size: 12px;
    color: var(--gray);
    padding-top: 15px;
    border-top: 1px solid #eee;
}

/* ============ Profile Hero ============ */
.profile-hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    padding: 40px 25px;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.profile-avatar {
    width: 90px;
    height: 90px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 700;
    margin: 0 auto 15px;
    border: 4px solid rgba(255,255,255,0.3);
}

.profile-hero h2 {
    font-size: 22px;
    margin-bottom: 6px;
}

.profile-position {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.profile-code {
    font-size: 13px;
    opacity: 0.8;
}

/* ============ Info Grid ============ */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 15px;
}

.info-item {
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: var(--radius-sm);
    border-right: 3px solid var(--primary);
}

.info-label {
    display: block;
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 4px;
}

.info-value {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    word-break: break-word;
}

@media (max-width: 600px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
    .profile-avatar {
        width: 75px;
        height: 75px;
        font-size: 32px;
    }
}

/* ============ Notifications ============ */
.notifications-list {
    display: flex;
    flex-direction: column;
}

.notification-item {
    display: flex;
    gap: 15px;
    padding: 18px 22px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    position: relative;
    align-items: flex-start;
}

.notification-item:hover {
    background: #f8f9ff;
    text-decoration: none;
}

.notification-item.unread {
    background: #f0f7ff;
}

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

.notification-icon {
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.notification-body {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 6px;
}

.notification-time {
    font-size: 11px;
    color: var(--gray);
}

.notification-dot {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 8px;
}

/* منع تحديد النص في الأزرار */
.btn,
.attendance-btn,
.stat-card,
.nav-menu a {
    -webkit-user-select: none;
    user-select: none;
}

/* دعم الوضع الليلي (اختياري) */
@media (prefers-color-scheme: dark) {
    /* يمكن تفعيله لاحقاً */
}

/* خلفية صفحة الدخول الزخرفية كانت تسبب تمريرًا أفقيًا (عنصر 200%) */
.login-body {
    overflow-x: hidden;
}

/* ============================================================
   N6 — استجابة كاملة (موبايل/تابلت) — كل القواعد داخل media screen
   لا تغيير على سطح المكتب أو الطباعة أو الهوية/الألوان.
   ============================================================ */

/* احترام المناطق الآمنة (notch) في واجهة الموظف */
@supports (padding: env(safe-area-inset-top)) {
    .navbar {
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
        padding-left: calc(20px + env(safe-area-inset-left, 0px));
        padding-right: calc(20px + env(safe-area-inset-right, 0px));
    }

    body {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

@media screen and (max-width: 768px) {
    .nav-toggle {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-menu.open {
        max-height: calc(100dvh - 80px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-menu a { min-height: 44px; display: flex; align-items: center; }

    .container { padding: 0 12px; }

    .form-row { grid-template-columns: 1fr; }

    /* الجداول: تمرير داخلي بدل كسر الصفحة */
    .table-responsive {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .card-body > table:not(.payslip-table) {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table th,
    .data-table td { padding: 9px 10px; font-size: 12.5px; }
    .data-table th { white-space: nowrap; }

    .payslip-print { padding: 16px; }
    .payslip-table th,
    .payslip-table td { padding: 8px; font-size: 12.5px; }
    .payslip-info { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

    .form-group input,
    .form-group select,
    .form-group textarea,
    .login-form input,
    .login-form select { font-size: 16px; }

    .btn { min-height: 44px; }
    .page-header .btn,
    .card-header .btn { min-height: 44px; }

    .modal { padding: 12px; }
    .modal-content { max-width: 95vw; max-height: 92dvh; overflow-y: auto; }
    .modal-close { min-width: 44px; min-height: 44px; }

    .toast { max-width: calc(100vw - 24px); }

    .att-calendar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .section-content table { display: block; overflow-x: auto; width: 100%; }

    .support-box,
    .guide-header { border-radius: 12px; }
}

@media screen and (max-width: 480px) {
    .navbar {
        padding: 10px 12px;
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
    }

    .container { padding: 0 10px; margin: 14px auto; }
    .card-body { padding: 16px; }
    .welcome-card,
    .profile-hero { padding: 20px 16px; }
    .page-header h2 { font-size: 19px; }
    .login-container { margin: 0 10px; }
    .att-stat .value { font-size: 20px; }
    .chapter-card { padding: 14px; }
    .chapter-icon { font-size: 30px; }
    .btn-block { width: 100%; }
}

/* أهداف لمس مريحة على أجهزة اللمس */
@media (pointer: coarse) {
    .btn,
    .nav-menu a,
    .month-btn,
    .chapter-card,
    .tab-btn { min-height: 44px; }
}

/* N6 — قائمة الموظف على الشاشات المتوسطة (≤1200):
   القائمة الأفقية الطويلة كانت تتجاوز العرض عند 1024px؛ تُطوى كقائمة منسدلة. */
@media screen and (max-width: 1200px) {
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        border-radius: 0 0 12px 12px;
        z-index: 95;
    }

    .nav-menu.open {
        max-height: calc(100dvh - 80px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px;
    }

    .nav-menu a {
        padding: 14px 16px;
        border-radius: 8px;
        font-size: 15px;
        white-space: normal;
    }
}


/* N6 — قص طبقة خلفية الدخول المتحركة (تمنع scrollWidth زائدًا من العنصر المُدوَّر) */.login-body { contain: paint; }
.login-body::before { animation: none; }

@media screen and (max-width: 600px) {
    .login-body::before { display: none; }
}


@media screen and (min-width: 601px) {
    .login-body::before { animation: rotate 60s linear infinite; }
}

