/* ===================== الخطوط ===================== */
@font-face {
    font-family: 'Qomra';
    src: url('../fonts/QOMRAARABICITF-MEDIUM.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Qomra';
    src: url('../fonts/QOMRAARABICITF-BLACK.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

/* ===================== المتغيرات ===================== */
:root {
    --teal-900: #062a2e;
    --teal-800: #0a3b40;
    --teal-700: #0f4f56;
    --teal-600: #14666f;
    --teal-500: #1a7d88;
    --teal-400: #26a3af;
    --teal-300: #4dc3cd;
    --teal-200: #a4e6ec;
    --teal-100: #e0f7fa;

    --accent:   #f5a623;
    --danger:   #e74c3c;
    --success:  #2ecc71;
    --warning:  #f39c12;

    --bg:       #3B838A;
    --surface:  #ffffff;
    --text:     #0b2a40;
    --text-dim: #5d7a88;
    --border:   #dbe7ec;
    --shadow-sm: 0 2px 6px rgba(6, 42, 46, .08);
    --shadow-md: 0 6px 20px rgba(6, 42, 46, .12);
    --shadow-lg: 0 16px 40px rgba(6, 42, 46, .18);
    --radius:   16px;
    --radius-sm: 10px;

    --header-h: 78px;
    --nav-h:    62px;
}

/* ===================== أساسيات ===================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Qomra', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}
html, body { min-height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    padding: 14px;
    padding-top: calc(var(--header-h) + 14px);
    padding-bottom: calc(var(--nav-h) + 10px);
    min-width: 320px;
    max-width: 900px;
    margin: 0 auto;
    font-size: 14px;
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
    min-height: -webkit-fill-available;
}
h1, h2, h3, h4, .company-name, .card-title, .login-title, .stat-card .value {
    font-weight: 800;
}

/* ===================== صفحة تسجيل الدخول ===================== */
.login-page {
    background: linear-gradient(135deg, var(--teal-800) 0%, var(--teal-600) 50%, var(--teal-900) 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: center;
    overflow: hidden;
    padding-top: 20px;
}
.login-page::before,
.login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(77, 195, 205, 0.12);
    animation: floaty 8s ease-in-out infinite;
}
.login-page::before { width: 320px; height: 320px; top: -120px; left: -120px; }
.login-page::after  { width: 260px; height: 260px; bottom: -100px; right: -100px; animation-delay: 2s; }

@keyframes floaty {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-22px); }
}

.login-container {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 36px 26px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    margin: 40px auto;
}
.logo-img {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--teal-400);
    box-shadow: 0 10px 28px rgba(26, 125, 136, .3);
    margin-bottom: 16px;
}
.login-title {
    color: var(--teal-800);
    font-size: 26px;
    letter-spacing: 1px;
}
.login-subtitle {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 26px;
}
.input-group { margin-bottom: 14px; text-align: right; }
.input-wrap { position: relative; }
.input-wrap i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--teal-600);
    font-size: 15px;
}
.input-wrap input {
    width: 100%;
    padding: 15px 44px 15px 18px;
    border: 2px solid var(--border);
    border-radius: 14px;
    font-size: 15px;
    background: #f8fcfd;
    color: var(--text);
    outline: none;
    transition: all .2s;
    font-family: 'Qomra', sans-serif;
    font-weight: 500;
}
.input-wrap input:focus {
    border-color: var(--teal-500);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(26, 125, 136, .12);
}
.login-btn {
    width: 100%;
    padding: 15px;
    margin-top: 22px;
    background: linear-gradient(135deg, var(--teal-700), var(--teal-500));
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform .15s, box-shadow .2s;
    box-shadow: 0 8px 22px rgba(15, 79, 86, .3);
    font-family: 'Qomra', sans-serif;
}
.login-btn:active { transform: scale(.97); }
.login-btn:disabled { opacity: .65; cursor: not-allowed; }
.loading-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 3px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-msg {
    display: none;
    color: var(--danger);
    background: #ffeaea;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 800;
    margin-top: 14px;
}
.version {
    margin-top: 20px;
    color: var(--text-dim);
    font-size: 12px;
}

/* ===================== الهيدر (ثابت) ===================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(135deg, var(--teal-700), var(--teal-500));
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #fff;
    box-shadow: var(--shadow-md);
    height: var(--header-h);
}
.app-header::after {
    content: '';
    position: absolute;
    inset: 0;
    max-width: 900px;
    margin: 0 auto;
    pointer-events: none;
}
.app-header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}
.app-header .brand img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.5);
    background: rgba(255,255,255,.15);
    cursor: pointer;
    flex-shrink: 0;
}
.app-header .brand-info { min-width: 0; flex: 1; }
.app-header .company-name {
    font-size: 18px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
.app-header .app-name {
    font-size: 12px;
    color: var(--teal-200);
    font-weight: 500;
}
.app-header .header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
    z-index: 2;
}
.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255,255,255,.18);
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.3); }

/* ===================== التنقل السفلي ===================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,.06);
    height: var(--nav-h);
}
.bottom-nav a {
    flex: 1;
    text-align: center;
    padding: 4px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: color .2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
}
.bottom-nav a i { font-size: 18px; }
.bottom-nav a.active { color: var(--teal-600); font-weight: 800; }

/* ===================== البطاقات ===================== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.card-title {
    font-size: 15px;
    color: var(--teal-800);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
    flex-wrap: wrap;
}
.card-title i { color: var(--accent); }
.card-title .badge {
    background: var(--teal-100);
    color: var(--teal-700);
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 50px;
    font-weight: 800;
}

/* ===================== إحصائيات الداشبورد ===================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.stat-card {
    background: linear-gradient(135deg, var(--teal-700), var(--teal-500));
    color: #fff;
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.stat-card.warn    { background: linear-gradient(135deg, #b56b0b, var(--warning)); }
.stat-card.danger  { background: linear-gradient(135deg, #a72a1c, var(--danger)); }
.stat-card.success { background: linear-gradient(135deg, #1a8b4a, var(--success)); }
.stat-card .value {
    font-size: 26px;
    line-height: 1.1;
}
.stat-card .label {
    font-size: 12px;
    opacity: .9;
    margin-top: 4px;
    font-weight: 500;
}

/* ===================== النماذج ===================== */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.field label {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-dim);
}
.field select,
.field input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: #f8fcfd;
    font-size: 14px;
    color: var(--text);
    outline: none;
    font-family: 'Qomra', sans-serif;
    font-weight: 500;
}
.field select:focus,
.field input:focus {
    border-color: var(--teal-500);
    background: #fff;
}
.field-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.field-row .field { flex: 1; min-width: 120px; }

/* ===================== الجداول ===================== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 500px;
}
thead {
    background: linear-gradient(135deg, var(--teal-700), var(--teal-500));
    color: #fff;
}
thead th {
    padding: 10px 12px;
    text-align: right;
    font-weight: 800;
    font-size: 12px;
    white-space: nowrap;
}
tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}
tbody tr:hover { background: #f0f8fa; cursor: pointer; }
tbody td {
    padding: 10px 12px;
    color: var(--text);
    font-size: 12px;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.emp-name {
    color: var(--teal-700);
    font-weight: 800;
    cursor: pointer;
}

/* ===================== شارة الحالة ===================== */
.status-badge {
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 800;
    display: inline-block;
    white-space: nowrap;
}
.status-badge.present { background: #d4edda; color: #155724; }
.status-badge.absent  { background: #f8d7da; color: #721c24; }
.status-badge.late    { background: #fff3cd; color: #856404; }
.status-badge.leave   { background: #cce5ff; color: #004085; }

/* ===================== الأزرار ===================== */
.btn {
    padding: 12px 18px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .15s;
    font-family: 'Qomra', sans-serif;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--teal-700), var(--teal-500)); color: #fff; }
.btn-outline { background: #fff; color: var(--teal-700); border: 2px solid var(--teal-500); }
.btn-danger  { background: var(--danger); color: #fff; }

/* ===================== حالة فارغة ===================== */
.empty {
    text-align: center;
    padding: 30px 16px;
    color: var(--text-dim);
}
.empty i {
    font-size: 38px;
    color: var(--teal-200);
    display: block;
    margin-bottom: 10px;
}

/* ===================== نافذة تأكيد الخروج ===================== */
.dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 42, 46, .55);
    backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.dialog-overlay.show { display: flex; }

.dialog-box {
    background: #fff;
    border-radius: 24px;
    padding: 28px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: popIn .25s ease;
}
@keyframes popIn {
    from { opacity: 0; transform: scale(.92); }
    to   { opacity: 1; transform: scale(1); }
}
.dialog-icon {
    font-size: 46px;
    color: var(--danger);
    margin-bottom: 10px;
}
.dialog-box h3 {
    color: var(--teal-800);
    font-size: 20px;
    margin-bottom: 6px;
}
.dialog-box p {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 22px;
}
.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.dialog-actions .btn { flex: 1; text-decoration: none; }

/* ===================== شاشة التحميل ===================== */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 42, 46, .55);
    backdrop-filter: blur(5px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.loading-overlay.show { display: flex; }

.loading-box {
    background: #fff;
    border-radius: 22px;
    padding: 32px 26px;
    max-width: 300px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: popIn .25s ease;
}
.loading-spinner-custom {
    width: 56px;
    height: 56px;
    border: 5px solid var(--teal-100);
    border-top-color: var(--teal-500);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 14px;
}
.loading-box h3 {
    color: var(--teal-800);
    font-size: 18px;
    margin-bottom: 4px;
}
.loading-box p {
    color: var(--text-dim);
    font-size: 13px;
}
.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* ===================== تجاوب ===================== */
@media (max-width: 400px) {
    body { padding: 10px; padding-top: calc(var(--header-h) + 10px); }
    .app-header { padding: 12px 14px; }
    .app-header .company-name { font-size: 16px; max-width: 160px; }
    .stat-card .value { font-size: 22px; }
    .login-container { padding: 28px 20px; }
    .logo-img { width: 88px; height: 88px; }
}

.bottom-spacer {
    height: calc(var(--nav-h) + 10px);
    width: 100%;
    pointer-events: none;
}