/* ============================================
   سامانه حضور و غیاب — دیزاین اپلیکیشنی
   ============================================ */

:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #3730a3;
    --gradient: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    --success: #10b981;
    --danger: #ef4444;
    --info: #0ea5e9;
    --dark: #0f172a;
    --dark-2: #1e293b;
    --bg: #eef2f7;
    --white: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --text-faint: #94a3b8;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 16px 50px rgba(15, 23, 42, 0.12);
    --sidebar-w: 260px;
    --font: 'IRANSansX', 'IRANSans', 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.8;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* ===== Utilities ===== */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.flex-1 { flex: 1; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.max-w-2xl { max-width: 44rem; }
.mx-auto { margin-right: auto; margin-left: auto; }
.text-center { text-align: center; }
.p-8 { padding: 2rem; }
.text-sm { font-size: 0.82rem; }
.text-muted { color: var(--text-faint); font-size: 0.85rem; }
.text-success { color: #059669; font-weight: 700; }
.text-danger { color: #dc2626; font-weight: 700; }

.grid-2, .grid-3 { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ============================================
   Layout — Desktop Sidebar & Mobile App
   ============================================ */
.app-container { min-height: 100vh; }

.sidebar {
    position: fixed; top: 0; right: 0;
    width: var(--sidebar-w); height: 100vh;
    background: linear-gradient(180deg, var(--dark) 0%, #16213e 100%);
    display: flex; flex-direction: column; z-index: 100;
}

.sidebar-header {
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex; align-items: center; gap: 12px; justify-content: center;
}
.logo-mark {
    width: 44px; height: 44px; background: var(--gradient);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.4); flex-shrink: 0;
}
.logo-mark svg { width: 22px; height: 22px; stroke: #fff; }
.sidebar-header h2 { color: #fff; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.3px; }

.sidebar-nav { flex: 1; padding: 1.25rem 1rem; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 0.8rem 1rem; margin-bottom: 0.4rem;
    color: #94a3b8; text-decoration: none;
    border-radius: 10px; font-weight: 500; font-size: 0.92rem;
    transition: all 0.25s ease; position: relative;
}
.nav-item svg { width: 19px; height: 19px; stroke: currentColor; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; transform: translateX(-3px); }
.nav-item.active {
    background: var(--gradient); color: #fff;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}
.nav-item.active::before {
    content: ''; position: absolute; right: -1rem; top: 50%;
    transform: translateY(-50%); width: 4px; height: 60%;
    background: #fff; border-radius: 4px;
}

.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.07); }
.logout-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 0.8rem;
    background: rgba(239, 68, 68, 0.12); color: #fca5a5;
    text-decoration: none; border-radius: 10px;
    font-weight: 600; font-size: 0.9rem; transition: all 0.25s;
}
.logout-btn:hover { background: #ef4444; color: #fff; }
.logout-btn svg { width: 17px; height: 17px; stroke: currentColor; }

.main-content {
    margin-right: var(--sidebar-w);
    padding: 1.75rem 2rem 3rem; min-height: 100vh;
}

/* ===== Top Bar ===== */
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.75rem; gap: 1rem; flex-wrap: wrap;
}
.top-bar h1 {
    font-size: 1.45rem; font-weight: 800; color: var(--dark);
    position: relative; padding-right: 1rem;
}
.top-bar h1::before {
    content: ''; position: absolute; right: 0; top: 8%;
    width: 5px; height: 85%; background: var(--gradient); border-radius: 5px;
}

.user-info {
    display: flex; align-items: center; gap: 0.7rem;
    background: var(--white); padding: 0.5rem 1.1rem 0.5rem 0.6rem;
    border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.user-info span { font-weight: 600; color: var(--text-light); font-size: 0.88rem; }
.user-avatar {
    width: 42px; height: 42px; background: var(--gradient); color: #fff;
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.05rem; box-shadow: 0 4px 12px rgba(79,70,229,0.35);
}

/* ============================================
   Auth Page — Glassmorphism & Animations
   ============================================ */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(-45deg, #0f172a, #312e81, #1e3a8a, #0f172a);
    background-size: 400% 400%; animation: gradientShift 14s ease infinite;
    padding: 1.5rem; position: relative; overflow: hidden;
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.auth-body::before, .auth-body::after {
    content: ''; position: absolute; border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,0.25), transparent 70%);
    animation: float 9s ease-in-out infinite;
}
.auth-body::before { width: 500px; height: 500px; top: -150px; right: -120px; }
.auth-body::after { width: 400px; height: 400px; bottom: -100px; left: -100px; animation-delay: 4s; }
@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-35px) scale(1.06); }
}

.auth-box {
    position: relative; z-index: 2;
    background: rgba(255, 255, 255, 0.97); backdrop-filter: blur(20px);
    padding: 3rem 2.5rem; border-radius: 24px;
    box-shadow: 0 25px 70px rgba(0,0,0,0.4); width: 100%; max-width: 420px;
    animation: slideUp 0.6s cubic-bezier(.16,1,.3,1);
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(35px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.auth-logo {
    width: 72px; height: 72px; margin: 0 auto 1.5rem; background: var(--gradient);
    border-radius: 20px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 12px 30px rgba(79,70,229,0.45); animation: pulse 2.5s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(79,70,229,0.5); }
    70% { box-shadow: 0 0 0 20px rgba(79,70,229,0); }
    100% { box-shadow: 0 0 0 0 rgba(79,70,229,0); }
}
.auth-logo svg { width: 34px; height: 34px; stroke: #fff; }
.auth-box h2 { text-align: center; font-size: 1.4rem; font-weight: 800; color: var(--dark); }
.auth-box > p { text-align: center; color: var(--text-light); margin-bottom: 1.75rem; font-size: 0.9rem; }

/* ============================================
   Cards, Forms & Animations
   ============================================ */
.card {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 1.5rem;
    border: 1px solid rgba(226, 232, 240, 0.7);
    overflow: visible; transition: all 0.3s ease;
    animation: fadeInUp 0.5s ease-out backwards;
}
.card:hover { box-shadow: var(--shadow-lg); }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.2s; }

.card-header {
    padding: 1.1rem 1.6rem; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; flex-wrap: wrap;
}
.card-header h3 { font-size: 1.02rem; font-weight: 700; color: var(--dark); }
.card-body { padding: 1.6rem; }

.form-group { margin-bottom: 1.15rem; }
.form-group > label {
    display: block; margin-bottom: 0.5rem;
    font-size: 0.85rem; font-weight: 600; color: var(--text-light);
}
.form-control {
    width: 100%; padding: 0.78rem 1rem;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.92rem; font-family: var(--font);
    background: #f8fafc; transition: all 0.25s ease; color: var(--text);
}
.form-control:hover { border-color: #cbd5e1; }
.form-control:focus {
    outline: none; border-color: var(--primary); background: var(--white);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.11);
}
textarea.form-control { resize: vertical; min-height: 70px; }
.form-control:disabled { background: #f1f5f9; color: var(--text-faint); cursor: not-allowed; }

/* ===== Buttons ===== */
.btn {
    padding: 0.8rem 1.6rem; border: none; border-radius: var(--radius-sm);
    cursor: pointer; font-weight: 600; font-size: 0.92rem; font-family: var(--font);
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem; transition: all 0.25s cubic-bezier(.4,0,.2,1);
    position: relative; overflow: hidden;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,23,42,0.18); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 5px 15px rgba(79,70,229,0.35); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: #fff; box-shadow: 0 5px 15px rgba(16,185,129,0.32); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; box-shadow: 0 5px 15px rgba(239,68,68,0.32); }
.btn-info { background: linear-gradient(135deg, #0ea5e9, #0284c7); color: #fff; box-shadow: 0 5px 15px rgba(14,165,233,0.32); }
.btn-light { background: var(--white); color: var(--text); border: 1.5px solid var(--border); }
.btn-light:hover { border-color: var(--primary); color: var(--primary); background: #eef2ff; }

/* ===== Tables ===== */
.table-container { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; }
table th {
    background: #f8fafc; padding: 0.95rem 1.4rem; text-align: right;
    font-size: 0.78rem; font-weight: 700; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: 0.4px;
    border-bottom: 1.5px solid var(--border); white-space: nowrap;
}
table td {
    padding: 0.95rem 1.4rem; text-align: right;
    border-bottom: 1px solid #f1f5f9; color: var(--text); white-space: nowrap;
}
table tbody tr { transition: background 0.18s ease; }
table tbody tr:hover { background: #f8faff; }
table tbody tr:last-child td { border-bottom: none; }

/* ===== Badges & Alerts ===== */
.badge {
    display: inline-block; padding: 0.3rem 0.75rem; border-radius: 20px;
    font-size: 0.74rem; font-weight: 700; letter-spacing: 0.2px;
}
.badge-success { background: #d1fae5; color: #047857; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0e7ff; color: #4338ca; }
.alert {
    padding: 0.9rem 1.2rem; border-radius: var(--radius-sm); margin-bottom: 1rem;
    font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 0.6rem;
    animation: fadeIn 0.3s ease;
}
.alert-success { background: #ecfdf5; color: #047857; border-right: 4px solid var(--success); }
.alert-error { background: #fef2f2; color: #b91c1c; border-right: 4px solid var(--danger); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== Search ===== */
.search-container { position: relative; margin-bottom: 1.25rem; }
.search-results {
    position: absolute; top: calc(100% + 6px); right: 0; left: 0;
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    max-height: 290px; overflow-y: auto; z-index: 50;
    animation: fadeInDown 0.2s ease;
}
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.search-item {
    padding: 0.85rem 1.15rem; border-bottom: 1px solid #f1f5f9;
    cursor: pointer; transition: background 0.15s;
    display: flex; align-items: center; gap: 0.75rem;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #eef2ff; }
.search-item .emp-avatar {
    width: 36px; height: 36px; background: var(--gradient); color: #fff;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}

.selected-user {
    display: flex; justify-content: space-between; align-items: center;
    background: linear-gradient(135deg, #eef2ff, #e0f2fe);
    padding: 1.1rem 1.4rem; border-radius: var(--radius-sm);
    margin-bottom: 1.25rem; border: 1.5px solid #c7d2fe;
    animation: fadeInUp 0.3s ease;
}
.selected-user span { font-size: 0.78rem; color: var(--text-light); }
.selected-user h4 { margin-top: 0.2rem; color: var(--primary-dark); font-size: 1.05rem; }

.filter-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.filter-form .form-group { flex: 1; min-width: 160px; margin-bottom: 0; }

/* ============================================
   Jalali Calendar
   ============================================ */
.date-picker-container { position: relative; }
.jalali-calendar {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 200;
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    width: 295px; padding: 1.1rem; animation: fadeInDown 0.25s ease;
}
.cal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.9rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}
.cal-header button {
    background: #f1f5f9; border: none; width: 32px; height: 32px;
    border-radius: 8px; cursor: pointer; font-weight: 800; color: var(--text-light); transition: all 0.2s;
}
.cal-header button:hover { background: var(--primary); color: #fff; }
.cal-title { font-weight: 700; color: var(--dark); font-size: 0.95rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-day-name { text-align: center; font-size: 0.75rem; color: var(--text-faint); padding: 6px 0; font-weight: 700; }
.cal-day {
    text-align: center; padding: 8px 0; font-size: 0.85rem; cursor: pointer;
    border-radius: 8px; transition: all 0.15s; color: var(--text);
}
.cal-day:hover { background: var(--gradient); color: #fff; font-weight: 700; }
.cal-day.disabled { color: #e2e8f0; cursor: default; }
.cal-day.disabled:hover { background: none; color: #e2e8f0; }
.cal-day.today { border: 1.5px solid var(--primary); font-weight: 800; color: var(--primary); }

/* ============================================
   Mobile App Layout (Bottom Nav)
   ============================================ */
.mobile-nav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(20px);
    border-top: 1px solid var(--border); padding: 8px 12px;
    justify-content: space-around; z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
}
.mobile-nav a {
    display: flex; flex-direction: column; align-items: center;
    text-decoration: none; color: var(--text-faint);
    font-size: 0.7rem; font-weight: 600; gap: 4px;
    transition: color 0.2s; flex: 1; padding: 5px 0;
}
.mobile-nav a svg { width: 22px; height: 22px; stroke: currentColor; }
.mobile-nav a.active { color: var(--primary); }
.mobile-nav a.active svg { filter: drop-shadow(0 2px 4px rgba(79,70,229,0.4)); }

@media print {
    .sidebar, .top-bar, .filter-form, .no-print, .mobile-nav { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    .card { border: none !important; box-shadow: none !important; }
    body { background: #fff !important; }
    .print-header { display: block !important; }
}

@media (max-width: 992px) {
    .sidebar { display: none; }
    .main-content { margin-right: 0; padding: 1rem 1rem 100px 1rem; }
    .mobile-nav { display: flex; }
    .top-bar { position: sticky; top: 0; background: rgba(238, 242, 247, 0.9); backdrop-filter: blur(10px); z-index: 50; margin: -1rem -1rem 1.5rem -1rem; padding: 1rem; border-radius: 0 0 20px 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
    .card { border-radius: 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .top-bar h1 { font-size: 1.15rem; }
}