/* ===========================================================================
   استایل اصلی سامانه‌ی منابع انسانی (ZHR)
   - راست‌چین (RTL) و فارسی
   - فونت وزیرمتن به‌صورت کاملاً محلی (بدون هیچ لینک خارجی)
   =========================================================================== */

/* ---- بارگذاری محلی فونت وزیرمتن ----------------------------------------- */
@font-face {
    font-family: 'Vazirmatn';
    src: url('/assets/fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/assets/fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/assets/fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ---- متغیرهای رنگ و طرح ------------------------------------------------- */
:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-bg: #f1f5f9;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-muted: #64748b;
    --color-border: #e2e8f0;
    --color-success-bg: #dcfce7;
    --color-success-text: #166534;
    --color-error-bg: #fee2e2;
    --color-error-text: #991b1b;
    --color-danger: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ---- بازنشانی پایه ------------------------------------------------------ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.7;
    font-size: 15px;
    direction: rtl;
}

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

/* ---- هدر برنامه -------------------------------------------------------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--color-surface);
    padding: 12px 24px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}
.app-header__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
}
.app-header__logo { font-size: 22px; }
.app-header__nav { display: flex; gap: 16px; }
.app-header__nav a { color: var(--color-text); font-weight: 500; }
.app-header__user { display: flex; align-items: center; gap: 12px; }
.app-header__username { color: var(--color-muted); font-size: 14px; }

/* ---- ناحیه‌ی اصلی و فوتر ----------------------------------------------- */
.app-main {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px;
}
.app-footer {
    text-align: center;
    color: var(--color-muted);
    font-size: 13px;
    padding: 24px;
}

/* ---- دکمه‌ها ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s, opacity .15s;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); }
.btn--ghost { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn--ghost:hover { background: var(--color-bg); }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--danger:hover { opacity: .9; }
.btn--sm { padding: 5px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- پیام‌های هشدار ----------------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert--success { background: var(--color-success-bg); color: var(--color-success-text); }
.alert--error { background: var(--color-error-bg); color: var(--color-error-text); }

/* ---- صفحات مهمان (لاگین/خطا) ------------------------------------------ */
.guest-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    padding: 16px;
}
.guest-container { width: 100%; max-width: 400px; }

.login-card, .error-card {
    background: var(--color-surface);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 32px;
}
.login-card__head { text-align: center; margin-bottom: 24px; }
.login-card__logo { font-size: 40px; }
.login-card__head h1 { font-size: 22px; margin: 8px 0 4px; }
.login-card__head p { color: var(--color-muted); font-size: 14px; }

.error-card { text-align: center; }
.error-card__code { font-size: 56px; font-weight: 700; color: var(--color-primary); }
.error-card__message { color: var(--color-muted); margin: 12px 0 20px; }

/* ---- فرم‌ها ------------------------------------------------------------ */
.form { display: flex; flex-direction: column; gap: 16px; }
.form__field { display: flex; flex-direction: column; gap: 6px; }
.form__label { font-size: 13px; font-weight: 500; color: var(--color-muted); }
.form__input {
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: #fff;
    color: var(--color-text);
    width: 100%;
}
.form__input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
textarea.form__input { resize: vertical; }

/* ---- پنل ادمین: چیدمان دو ستونی --------------------------------------- */
.admin-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 20px;
    align-items: start;
}
.admin-sidebar {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    position: sticky;
    top: 16px;
}
.admin-sidebar__list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.admin-sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--color-text);
    font-size: 14px;
    font-weight: 500;
}
.admin-sidebar__link:hover { background: var(--color-bg); text-decoration: none; }
.admin-sidebar__link--active { background: var(--color-primary); color: #fff; }
.admin-sidebar__icon { font-size: 16px; }

.admin-content {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    min-width: 0;
}
.admin-content__title { font-size: 20px; margin-bottom: 8px; }
.admin-content__hint { color: var(--color-muted); font-size: 13px; margin-bottom: 16px; }

/* ---- کارت‌های آمار ----------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 20px;
    background: var(--color-bg);
    border-radius: var(--radius);
    color: var(--color-text);
}
.stat-card:hover { background: #e6ecf5; text-decoration: none; }
.stat-card__icon { font-size: 28px; }
.stat-card__value { font-size: 28px; font-weight: 700; color: var(--color-primary); }
.stat-card__label { font-size: 13px; color: var(--color-muted); }

.info-box {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.info-box h2 { font-size: 16px; margin-bottom: 10px; }
.info-box ol { padding-right: 20px; line-height: 2.2; }

/* ---- کارت فرم (قابل بازشدن) ------------------------------------------- */
.form-card {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
}
.form-card--static { padding: 20px; }
.form-card__summary {
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    margin-bottom: 12px;
}
details.form-card > summary { list-style: none; }
details.form-card > summary::-webkit-details-marker { display: none; }

/* ---- فرم شبکه‌ای (چندستونی) ------------------------------------------- */
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 12px;
}
.form__field--wide { grid-column: 1 / -1; }
.grid-form__actions { grid-column: 1 / -1; }

.fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.fieldset legend { font-weight: 700; padding: 0 8px; }

/* ---- جدول داده --------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
    text-align: right;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
}
.data-table th { color: var(--color-muted); font-weight: 500; background: var(--color-bg); }
.data-table--compact th, .data-table--compact td { padding: 7px 10px; font-size: 13px; }
.data-table__empty { text-align: center; color: var(--color-muted); padding: 24px; }
.data-table__actions { display: flex; gap: 6px; }
.edit-row > td { background: #f8fafc; }
.inline-form { display: inline; }

/* ---- نشان‌های وضعیت ---------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.badge--done, .badge--held { background: var(--color-success-bg); color: var(--color-success-text); }
.badge--in_progress { background: #fef3c7; color: #92400e; }
.badge--todo, .badge--planned { background: #e0e7ff; color: #3730a3; }

/* ---- چیپ‌ها (دانلود قالب) --------------------------------------------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
    display: inline-block;
    padding: 6px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 13px;
}
.chip:hover { border-color: var(--color-primary); text-decoration: none; }

.mt { margin-top: 14px; }
.hint { font-size: 12px; color: var(--color-muted); margin-top: 8px; }
.hint--warn { color: #b45309; }
code { background: #e2e8f0; padding: 2px 6px; border-radius: 6px; font-family: monospace; }

/* ===========================================================================
   چت‌بات
   =========================================================================== */
.chat {
    max-width: 760px;
    margin: 0 auto;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 400px;
    overflow: hidden;
}
.chat__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}
.chat__header h1 { font-size: 18px; }
.chat__header p { color: var(--color-muted); font-size: 13px; }

.chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.chat-bubble { display: flex; max-width: 80%; }
.chat-bubble--user { align-self: flex-start; }
.chat-bubble--bot { align-self: flex-end; }
.chat-bubble__text {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-bubble--user .chat-bubble__text { background: var(--color-primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble--bot .chat-bubble__text { background: var(--color-bg); color: var(--color-text); border-bottom-left-radius: 4px; }
.chat-bubble--typing .chat-bubble__text { color: var(--color-muted); font-style: italic; }

.chat__form {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--color-border);
    align-items: flex-end;
}
.chat__input {
    flex: 1;
    font-family: inherit;
    font-size: 14px;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    resize: none;
    max-height: 120px;
}
.chat__input:focus { outline: none; border-color: var(--color-primary); }

/* ---- واکنش‌گرایی (موبایل) --------------------------------------------- */
@media (max-width: 820px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; }
    .admin-sidebar__list { flex-direction: row; flex-wrap: wrap; }
    .app-header { justify-content: center; text-align: center; }
}
