/*
|--------------------------------------------------------------------------
| استایل پایه سامانه (نسخه دست‌نویس موقت)
|--------------------------------------------------------------------------
|
| دلیل وجود: در این محیط به Tailwind CLI دسترسی نیست؛ بنابراین یک استایل
| کوچک و کامل دست‌نویس شده تا صفحه‌ها بدون هیچ منبع بیرونی و بدون خطای
| کنسول رندر شوند. منابع و دستور ساخت Tailwind در resources/css/app.css و
| tools/README.md مستند شده‌اند؛ پس از دانلود CLI، همین فایل بازنویسی می‌شود.
|
| قواعد: RTL، بدون dark mode، بدون inline style، فونت محلی وزیرمتن.
|
*/

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

:root {
    --color-bg: #f6f7f9;
    --color-surface: #ffffff;
    --color-border: #e2e5ea;
    --color-text: #1f2937;
    --color-muted: #5b6472;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-danger: #dc2626;
    --color-success: #15803d;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
    --font: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.8;
}

h1, h2, h3 { line-height: 1.4; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 0.75rem; }

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

/*
| هر عنصر دارای attribute مخفی باید واقعاً پنهان باشد؛ کلاس‌هایی مثل
| .modal-root که display تعریف می‌کنند نباید hidden را خنثی کنند.
*/
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 1rem; }

/* پرش به محتوا برای صفحه‌خوان‌ها */
.skip-link {
    position: absolute;
    inset-inline-start: -9999px;
    top: 0.5rem;
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    z-index: 60;
}
.skip-link:focus { inset-inline-start: 0.5rem; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* پوسته و سربرگ */
.app-body { min-height: 100%; display: flex; flex-direction: column; }
.app-main { flex: 1; padding: 1.5rem 0 3rem; }

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 30;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 60px;
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--color-text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--color-primary); font-size: 1.2rem; }
.site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.nav-link {
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    color: var(--color-muted);
    font-size: 0.95rem;
}
.nav-link:hover { background: #eef2ff; color: var(--color-primary-dark); text-decoration: none; }
.nav-link[aria-current='page'] { background: #e0e7ff; color: var(--color-primary-dark); }

/* سرصفحه صفحه */
.page-header { margin-bottom: 1.25rem; }
.eyebrow { color: var(--color-muted); font-size: 0.85rem; margin-bottom: 0.25rem; }
.lead { color: var(--color-muted); max-width: 62ch; }

/* شبکه و کارت‌ها */
.grid { display: grid; gap: 1rem; }
.grid-cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1rem;
}
.card-title { font-size: 1.05rem; margin-bottom: 0.35rem; }
.card-text { color: var(--color-muted); margin: 0; font-size: 0.95rem; }

.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }

/* دکمه‌ها */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.5rem 1.1rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:disabled, .btn[aria-busy='true'] { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn-ghost { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn-ghost:hover { background: #f1f5f9; text-decoration: none; }
.btn-danger { background: var(--color-danger); color: #fff; }

/* فرم‌ها */
.field { display: block; margin-bottom: 0.75rem; }
.field-label { display: block; font-size: 0.9rem; color: var(--color-muted); margin-bottom: 0.25rem; }
.field-input {
    width: 100%;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: inherit;
    font-size: 1rem;
}
.field-input:focus { outline: 2px solid #bfdbfe; border-color: var(--color-primary); }
.field-hint { color: var(--color-muted); font-size: 0.85rem; margin: 0.35rem 0 0; }
.field-error { color: var(--color-danger); font-size: 0.85rem; margin-top: 0.25rem; }

/* تقویم شمسی */
.datepicker { position: relative; }
.datepicker-field { display: flex; gap: 0.5rem; align-items: stretch; }
.datepicker-field .field-input { flex: 1; }
.datepicker-popover {
    position: absolute;
    z-index: 40;
    margin-top: 0.4rem;
    width: min(320px, 92vw);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
    padding: 0.75rem;
}
.datepicker-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.datepicker-title { font-weight: 700; font-size: 0.95rem; }
.datepicker-nav {
    min-width: 36px; min-height: 36px; border-radius: 8px;
    border: 1px solid var(--color-border); background: var(--color-surface); cursor: pointer;
}
.datepicker-nav:disabled { opacity: 0.4; cursor: not-allowed; }
.datepicker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.datepicker-weekday { text-align: center; font-size: 0.75rem; color: var(--color-muted); padding: 0.25rem 0; }
.datepicker-day {
    min-height: 36px; border-radius: 8px; border: 1px solid transparent;
    background: transparent; color: var(--color-text); font-family: inherit;
    font-size: 0.9rem; cursor: pointer;
}
.datepicker-day:hover:not(:disabled) { background: #eef2ff; }
.datepicker-day[aria-selected='true'] { background: var(--color-primary); color: #fff; }
.datepicker-day[aria-current='date'] { border-color: var(--color-primary); font-weight: 700; }
.datepicker-day:disabled { color: #c3c8d1; cursor: not-allowed; }
.datepicker-error { color: var(--color-danger); font-size: 0.85rem; margin-top: 0.5rem; }

/* نمودار */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }

/* toast */
.toast-root {
    position: fixed;
    inset-block-end: 1rem;
    inset-inline-start: 1rem;
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(360px, 92vw);
}
.toast {
    display: flex; align-items: flex-start; gap: 0.5rem;
    background: #111827; color: #fff;
    border-radius: 10px; padding: 0.6rem 0.9rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
    font-size: 0.9rem;
}
.toast[data-type='success'] { background: var(--color-success); }
.toast[data-type='error'] { background: var(--color-danger); }
.toast[data-type='warn'] { background: #b45309; }
.toast-close {
    margin-inline-start: auto; background: transparent; border: 0; color: inherit;
    cursor: pointer; font-size: 1rem; line-height: 1;
}

/* مودال */
.modal-root {
    position: fixed; inset: 0; z-index: 80;
    display: grid; place-items: center;
    background: rgba(15, 23, 42, 0.45);
    padding: 1rem;
}
.modal-card {
    width: min(420px, 100%);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
    padding: 1.25rem;
}
.modal-title { font-size: 1.05rem; margin-bottom: 0.5rem; }
.modal-text { color: var(--color-muted); }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-start; margin-top: 1rem; }

/* نوار بارگذاری */
.loading-bar {
    position: fixed; inset-block-start: 0; inset-inline: 0;
    height: 3px; z-index: 90; background: transparent; overflow: hidden;
}
.loading-bar-fill {
    display: block; height: 100%; width: 40%;
    background: var(--color-primary);
    animation: loading-slide 1s ease-in-out infinite;
}
@keyframes loading-slide {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-260%); }
}

/* صفحه‌های خطا */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.error-card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 2rem; max-width: 460px; text-align: center;
}
.error-code { font-size: 3rem; font-weight: 700; color: var(--color-primary); margin: 0; line-height: 1; }
.error-heading { font-size: 1.25rem; margin-top: 0.75rem; }
.error-text { color: var(--color-muted); }

/* احترام به کاهش حرکت */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* موبایل */
@media (max-width: 600px) {
    h1 { font-size: 1.35rem; }
    .header-inner { min-height: 54px; }
    .brand-name { font-size: 0.95rem; }
    .card { padding: 0.95rem 1rem; }
    .chart-box { height: 220px; }
}

/* ---------- فاز ۳: ورود، جدول دانش‌آموزان و داشبورد ---------- */

/* دکمه‌های کوچک و تمام‌عرض */
.btn-sm { min-height: 36px; padding: 0.3rem 0.7rem; font-size: 0.85rem; border-radius: 8px; }
.btn-block { width: 100%; }

/* صفحه ورود */
.auth-page { display: grid; place-items: center; padding-top: 1rem; }
.auth-container { display: flex; justify-content: center; }
.auth-card { width: min(440px, 100%); }
.form-error { display: block; margin-top: 0.5rem; }

/* نوار فیلتر */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.toolbar-field { margin: 0; min-width: 190px; flex: 1 1 190px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.panel { margin-top: 1rem; }

/* جدول داده */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th, .data-table td {
    padding: 0.55rem 0.5rem;
    text-align: start;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.data-table th { color: var(--color-muted); font-weight: 500; font-size: 0.85rem; }
.table-empty { text-align: center; color: var(--color-muted); padding: 1.5rem 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* نشان وضعیت */
.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    line-height: 1.6;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* کارت‌های آماری */
.stat-value { font-size: 1.9rem; font-weight: 700; margin: 0.25rem 0 0; }

/* صفحه‌بندی */
.pagination { display: flex; align-items: center; gap: 0.5rem; justify-content: center; margin-top: 1rem; }
.pagination-info { color: var(--color-muted); font-size: 0.85rem; }

/* گزینه‌های رادیویی بازنشانی رمز */
.radio-row { display: flex; align-items: center; gap: 0.4rem; min-height: 36px; font-size: 0.92rem; }

/* نمایش یک‌باره رمز تولیدشده */
.generated-password { margin-top: 1rem; border-top: 1px dashed var(--color-border); padding-top: 0.75rem; }
.generated-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.generated-code {
    direction: ltr;
    font-family: Consolas, monospace;
    background: #f1f5f9;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.4rem 0.7rem;
    font-size: 0.95rem;
}

/* دکمه خروج در ناوبری */
.nav-logout {
    background: transparent;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
}

/* ---------- فاز ۴: کاتالوگ و انتخاب‌گر دانش‌آموز ---------- */

.text-muted { color: var(--color-muted); }
.visibility-cell { white-space: normal; min-width: 16rem; }
.visibility-names { display: block; margin-top: 0.25rem; font-size: 0.82rem; color: var(--color-muted); }
.badge-global { background: #dbeafe; color: #1e40af; }
.badge-assigned { background: #ede9fe; color: #5b21b6; }

/* انتخاب‌گر چندگانه دانش‌آموز */
.visibility-picker { margin: 0.5rem 0 0.75rem; }
.student-picker { border: 1px solid var(--color-border); border-radius: 10px; background: #fcfcfd; }
.picker-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
    padding: 0.6rem; border-bottom: 1px solid var(--color-border);
}
.picker-search { flex: 1 1 180px; min-height: 38px; }
.picker-count { color: var(--color-muted); font-size: 0.82rem; margin-inline-start: auto; }
.picker-list {
    list-style: none; margin: 0; padding: 0.35rem;
    max-height: 220px; overflow-y: auto;
}
.picker-list li[hidden] { display: none; }
.picker-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0.5rem; border-radius: 8px; cursor: pointer;
}
.picker-row:hover { background: #eef2ff; }
.picker-row input[type="checkbox"] { width: 18px; height: 18px; }
.picker-name { font-size: 0.92rem; }
.picker-username { font-size: 0.8rem; color: var(--color-muted); margin-inline-start: auto; }

/* ---------- فاز ۵: خط زمانی ردیف‌ها و فرم‌ها ---------- */

.entries-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; }
.date-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-inline-start: auto; }
.entries-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.entries-side { display: flex; flex-direction: column; gap: 0.75rem; }

.entry-card {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.65rem;
    background: #fff;
}
.entry-time { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
.entry-range { font-weight: 700; font-size: 1rem; }
.entry-duration { color: var(--color-muted); font-size: 0.82rem; }
.entry-head { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.entry-title { font-size: 0.98rem; }
.entry-note { margin: 0.35rem 0 0; color: var(--color-muted); font-size: 0.88rem; white-space: pre-wrap; }
.entry-actions { display: flex; gap: 0.35rem; margin-top: 0.45rem; flex-wrap: wrap; }
.entry-edit { margin-top: 0.7rem; border-top: 1px dashed var(--color-border); padding-top: 0.7rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; }
.form-grid .field { margin-bottom: 0.25rem; }
.field-wide { grid-column: 1 / -1; }
.form-grid-times { grid-template-columns: 1fr 1fr; }

@media (max-width: 760px) {
    .entries-layout { grid-template-columns: 1fr; }
    .date-nav { margin-inline-start: 0; }
}

/* ---------- فاز ۶: جریمه، قواعد و رنگ‌ها ---------- */

.debt-card {
    border: 2px solid var(--color-border);
    border-radius: 14px;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    background: #fff;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.debt-value { font-size: 2rem; font-weight: 800; margin: 0.2rem 0; }
.effect-positive { color: #b91c1c; font-weight: 700; }
.effect-negative { color: #15803d; font-weight: 700; }

.weekday-grid { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 0.6rem 0; }
.weekday-row {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    border: 1px solid var(--color-border); border-radius: 10px; padding: 0.45rem 0.6rem;
}
.weekday-values { display: flex; gap: 0.35rem; }
.weekday-values .field-input { width: 5.5rem; min-height: 34px; }
.checkbox-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }

.color-input { display: flex; flex-direction: column; gap: 0.45rem; }
.color-swatches { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.color-swatch {
    width: 26px; height: 26px; border-radius: 6px; border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--color-border); cursor: pointer; padding: 0;
}
.color-swatch.is-selected { box-shadow: 0 0 0 2px var(--color-text); }
.color-hex { max-width: 9rem; font-family: monospace; }
.color-chip {
    display: inline-block; width: 18px; height: 18px; border-radius: 4px;
    border: 1px solid var(--color-border); vertical-align: middle; margin-inline-end: 0.35rem;
}
.color-group { margin-bottom: 1rem; }
.color-form { border-top: 1px dashed var(--color-border); padding-top: 0.7rem; margin-top: 0.8rem; }
.color-form-edit { background: #f8fafc; }
.card-subtitle { font-size: 1rem; margin: 0.8rem 0 0.2rem; }

/* ---------- فاز ۷: گزارش‌ها، نمودارها و تقویم ماه ---------- */

.grid-charts { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin: 1rem 0; }
.chart-card { display: flex; flex-direction: column; }
.chart-box { position: relative; min-height: 240px; height: 260px; }
.chart-box canvas { max-width: 100%; }

.heatmap {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.3rem;
    margin-top: 0.6rem;
}
.heatmap-head { text-align: center; font-size: 0.78rem; color: var(--color-muted); padding: 0.2rem 0; }
.heatmap-cell {
    min-height: 46px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #111827;
}
.heatmap-cell.is-empty { background: transparent; border-color: transparent; }
.heatmap-cell.is-today { outline: 2px solid var(--color-text); outline-offset: 1px; }
.heatmap-day { font-weight: 700; }

.ledger-scroll { max-height: 360px; overflow: auto; }
.pagination-wrap { margin-top: 0.8rem; }
.toolbar-field { min-width: 220px; }
.btn.is-active { background: var(--color-primary); color: #fff; }

@media (max-width: 640px) {
    .grid-charts { grid-template-columns: 1fr; }
    .chart-box { height: 220px; }
    .heatmap-cell { min-height: 38px; font-size: 0.72rem; }
}
