/* ============================================================
   styles.css — استایل‌های سیستم مدیریت مرخصی
   ============================================================ */

:root {
    --primary: #4F46E5;
    --bg: #F3F4F6;
    --card: #FFFFFF;
    --text: #1F2937;
    --border: #E5E7EB;
}
[data-theme="dark"] {
    --primary: #818CF8;
    --bg: #111827;
    --card: #1F2937;
    --text: #F9FAFB;
    --border: #374151;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 20px;
    transition: background-color 0.2s, color 0.2s;
}
.container {
    max-width: 1200px;
    margin: 0 auto;
}
h1, h2 {
    color: var(--primary);
}
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}
.card {
    background: var(--card);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    text-align: center;
}
.card h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #6B7280;
}
.card .value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
}
.card .sub-text {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 5px;
}
.form-section {
    background: var(--card);
    padding: 32px 36px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    margin: 0 auto 30px auto;
    max-width: 700px;
}
.form-section .form-title {
    margin: 0 0 6px 0;
    font-size: 22px;
    color: var(--text);
}
.form-section .form-subtitle {
    margin: 0 0 28px 0;
    font-size: 13px;
    color: #6B7280;
}
.form-section .form-subtitle .req {
    color: #EF4444;
    font-weight: bold;
}
.form-grid {
    display: flex;
    flex-direction: column;
}
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}
.form-group label {
    font-weight: 700;
    font-size: 14px;
    color: #374151;
    margin-bottom: 8px;
    text-align: right;
}
.form-group label .req {
    color: #EF4444;
    margin-right: 3px;
}
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}
.form-actions .btn-submit {
    flex: 1;
    padding: 13px 20px;
    font-size: 15px;
}
.btn-cancel {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 13px 20px;
    font-size: 15px;
}
.btn-cancel:hover {
    background: var(--primary);
    color: white;
}
.btn-cancel.hidden {
    display: none;
}
input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
textarea {
    resize: vertical;
    min-height: 100px;
    font-family: monospace;
    font-size: 12px;
    direction: ltr;
    text-align: left;
}
button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}
button:hover {
    background-color: #4338CA;
}
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-danger {
    background-color: #EF4444;
    padding: 5px 10px;
    font-size: 12px;
}
.btn-danger:hover {
    background-color: #DC2626;
}
.btn-copy {
    background-color: #10B981;
    padding: 5px 10px;
    font-size: 12px;
}
.btn-copy:hover {
    background-color: #059669;
}
.btn-edit {
    background-color: #F59E0B;
    padding: 5px 10px;
    font-size: 12px;
}
.btn-edit:hover {
    background-color: #D97706;
}
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    color: white;
}
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
th, td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}
th {
    background-color: #F9FAFB;
    color: #6B7280;
    font-weight: 600;
}
tr:hover {
    background-color: #F9FAFB;
}
.actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: flex-end;
}
.link-cell a {
    color: var(--primary);
    text-decoration: none;
}
.link-cell a:hover {
    text-decoration: underline;
}
.row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.import-section {
    background: #EEF2FF;
    border: 1px dashed #A5B4FC;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
}
.import-section.active {
    display: block;
}
.settings-section {
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
.settings-section label {
    font-weight: bold;
    color: #166534;
    white-space: nowrap;
}
.settings-section input {
    max-width: 300px;
}
.helper-text {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    color: #9CA3AF;
}
.toast {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #10B981;
    color: #fff;
    padding: 12px 22px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 9999;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.undo-toast {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1F2937;
    color: #fff;
    padding: 12px 22px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
}
.undo-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
.undo-toast .undo-link {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: bold;
}
@media (max-width: 768px) {
    .form-section {
        padding: 22px 18px;
    }
    .form-actions {
        flex-direction: column;
    }
    table {
        display: block;
        overflow-x: auto;
    }
    .row-actions {
        flex-direction: column;
    }
}
.backup-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FCD34D;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 14px;
}
.backup-banner button {
    background: #B45309;
    color: #fff;
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
}
.backup-banner button:hover {
    background: #92400E;
}
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 160px;
    min-width: 140px;
}
.filter-bar .filter-group label {
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    text-align: right;
}
.filter-bar .filter-group input,
.filter-bar .filter-group select {
    padding: 9px 10px;
    font-size: 13px;
}
.filter-bar .filter-actions {
    flex: 0 0 auto;
    justify-content: flex-end;
}
.filter-bar .filter-actions button {
    padding: 9px 14px;
    font-size: 13px;
    white-space: nowrap;
}
/* ==== مودال آمار ==== */
.stats-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 30px 15px;
    overflow-y: auto;
    z-index: 10001;
}
.stats-overlay.show {
    display: flex;
}
.stats-card {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 1000px;
    padding: 24px 28px 32px 28px;
    position: relative;
}
.stats-card .stats-title {
    margin: 0 0 20px 0;
    font-size: 22px;
    color: var(--primary);
    text-align: center;
}
.stats-close {
    position: absolute;
    top: 12px;
    left: 12px;
    background: transparent;
    color: var(--text);
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
}
.stats-close:hover {
    background: var(--border);
}
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}
@media (min-width: 900px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .stats-grid .stats-chart-full {
        grid-column: 1 / -1;
    }
}
.stats-chart-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}
.stats-chart-box h3 {
    margin: 0 0 12px 0;
    font-size: 15px;
    color: var(--text);
    text-align: center;
}
.stats-chart-box .chart-wrap {
    position: relative;
    height: 300px;
}
.stats-empty {
    text-align: center;
    padding: 60px 20px;
    font-size: 18px;
    color: var(--text);
    opacity: 0.8;
}
/* ==== کنترل بازه‌ای (Segmented Control) آمار ==== */
.stats-segment {
    display: flex;
    width: 100%;
    max-width: 480px;
    margin: 0 auto 24px auto;
    border: 1px solid var(--primary);
    border-radius: 10px;
    overflow: hidden;
    background: var(--card);
}
.stats-segment button {
    flex: 1 1 0;
    background: transparent;
    color: var(--primary);
    border: none;
    border-radius: 0;
    padding: 11px 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.stats-segment button + button {
    border-right: 1px solid var(--primary);
}
.stats-segment button:hover {
    background: rgba(79, 70, 229, 0.12);
}
.stats-segment button.active {
    background: var(--primary);
    color: #FFFFFF;
}
.stats-segment button.active:hover {
    background: var(--primary);
}
.stats-segment.hidden {
    display: none;
}

/* ============================================================
   استایل‌های جدید: احراز هویت، بارگذاری، آفلاین، مهاجرت، خطا
   ============================================================ */

/* ---- پنهان‌سازی اپ تا زمان آماده شدن ---- */
#appRoot.hidden {
    display: none;
}

/* ---- نوار آفلاین ---- */
.offline-banner {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}
.offline-banner.show {
    display: flex;
}

/* ---- نوار وضعیت همگام‌سازی ---- */
.sync-banner {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #E0E7FF;
    color: #3730A3;
    border: 1px solid #A5B4FC;
    border-radius: 10px;
    padding: 10px 18px;
    margin-bottom: 20px;
    font-size: 13px;
    text-align: center;
}
.sync-banner.show {
    display: flex;
}

/* ---- دکمه خروج در هدر ---- */
.btn-logout {
    background: transparent;
    color: #EF4444;
    border: 1px solid #EF4444;
}
.btn-logout:hover {
    background: #EF4444;
    color: #fff;
}
.user-email {
    font-size: 12px;
    color: #6B7280;
    margin-left: 8px;
    direction: ltr;
    display: inline-block;
}

/* ---- پوشش تمام‌صفحه (ورود / بارگذاری / خطا) ---- */
.fullscreen-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 20000;
    overflow-y: auto;
}
.fullscreen-overlay.show {
    display: flex;
}

/* ---- کارت ورود ---- */
.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 420px;
    padding: 36px 32px;
    text-align: center;
}
.auth-card .auth-logo {
    font-size: 40px;
    margin-bottom: 8px;
}
.auth-card h2 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: var(--primary);
}
.auth-card .auth-subtitle {
    margin: 0 0 24px 0;
    font-size: 13px;
    color: #6B7280;
    line-height: 1.7;
}
.auth-card .auth-field {
    text-align: right;
    margin-bottom: 16px;
}
.auth-card .auth-field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 6px;
}
.auth-card .auth-btn {
    width: 100%;
    padding: 13px 20px;
    font-size: 15px;
}
.auth-message {
    display: none;
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.7;
    text-align: right;
}
.auth-message.show {
    display: block;
}
.auth-message.success {
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #86EFAC;
}
.auth-message.error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}
.auth-message.info {
    background: #E0E7FF;
    color: #3730A3;
    border: 1px solid #A5B4FC;
}

/* ---- اسپینر بارگذاری ---- */
.spinner-box {
    text-align: center;
    color: var(--text);
}
.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 18px auto;
    animation: spin 0.9s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner-box .spinner-text {
    font-size: 15px;
    font-weight: bold;
    color: var(--primary);
}

/* ---- صفحه خطا ---- */
.error-card {
    background: var(--card);
    border: 1px solid #FCA5A5;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 460px;
    padding: 36px 32px;
    text-align: center;
}
.error-card .error-icon {
    font-size: 44px;
    margin-bottom: 10px;
}
.error-card h2 {
    margin: 0 0 12px 0;
    font-size: 19px;
    color: #EF4444;
}
.error-card p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--text);
    line-height: 1.8;
}
.error-card .error-hint {
    font-size: 12px;
    color: #6B7280;
    direction: ltr;
    text-align: center;
    background: var(--bg);
    border-radius: 8px;
    padding: 10px;
    margin-top: 14px;
    word-break: break-all;
}

/* ---- مودال مهاجرت ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 20001;
}
.modal-overlay.show {
    display: flex;
}
.modal-card {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 480px;
    padding: 28px 26px;
    text-align: center;
}
.modal-card .modal-icon {
    font-size: 40px;
    margin-bottom: 8px;
}
.modal-card h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    color: var(--primary);
}
.modal-card p {
    margin: 0 0 22px 0;
    font-size: 14px;
    line-height: 1.9;
    color: var(--text);
}
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.modal-actions button {
    padding: 11px 22px;
    font-size: 14px;
}
.modal-actions .btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.modal-actions .btn-secondary:hover {
    background: var(--border);
}
