@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
    --ink:        #1c2b2e;
    --slate:      #2f4858;
    --slate-dark: #1e3038;
    --teal:       #2f6f6a;
    --teal-dark:  #23524e;
    --paper:      #f6f4ef;
    --card:       #ffffff;
    --line:       #e2e0d8;
    --amber:      #c98a2e;
    --amber-bg:   #fbf0dd;
    --red:        #b5432f;
    --red-bg:     #fbe7e2;
    --green:      #3d7a53;
    --green-bg:   #e5f1e7;
    --radius: 10px;
    --shadow: 0 2px 10px rgba(30, 48, 56, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ------------------------- دکمه‌ها ------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 18px; border-radius: var(--radius); border: none;
    font-size: 14px; font-weight: 600; transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-ghost { background: transparent; color: var(--slate); border: 1px solid var(--line); }
.btn-ghost:hover { background: #fff; }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ------------------------- صفحه ورود ------------------------- */
.auth-page, .customer-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
    background: var(--card); border-radius: 16px; padding: 36px 28px;
    max-width: 380px; width: 100%; box-shadow: var(--shadow); text-align: center;
}
.brand { font-size: 26px; font-weight: 800; color: var(--slate-dark); margin: 0 0 4px; }
.brand span { color: var(--teal); }
.auth-sub { color: #6b7a7e; margin-bottom: 22px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; text-align: right; }
.auth-form label { font-size: 13px; color: var(--slate); display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
    padding: 11px 14px; border-radius: 8px; border: 1px solid var(--line); font-size: 15px;
    font-family: inherit; background: #fcfbf8;
}
.auth-form input:focus { border-color: var(--teal); }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; text-align: right; }
.alert-error { background: var(--red-bg); color: var(--red); }

/* ------------------------- چیدمان اصلی ------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas: "topbar topbar" "sidebar content";
    min-height: 100vh;
}
.topbar {
    grid-area: topbar; background: var(--slate-dark); color: #fff;
    display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
    position: sticky; top: 0; z-index: 20;
}
.brand-mini { font-weight: 800; font-size: 17px; }
.brand-mini span { color: #8fd0c8; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.tenant-name { opacity: .85; }
.menu-toggle {
    display: none; background: none; border: none; color: #fff; font-size: 20px;
}

.sidebar {
    grid-area: sidebar; background: var(--slate); color: #fff; padding: 18px 0;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar .nav-link {
    display: block; padding: 12px 22px; font-size: 14.5px; color: #cfe0dd;
    border-right: 3px solid transparent;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,0.06); }
.sidebar .nav-link.active { color: #fff; border-right-color: var(--teal); background: rgba(255,255,255,0.08); font-weight: 600; }

.content { grid-area: content; padding: 24px; overflow-x: auto; }

/* ------------------------- کارت‌های آمار ------------------------- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.stat-card {
    background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
    border-right: 4px solid var(--teal);
}
.stat-card.overdue { border-right-color: var(--red); }
.stat-card.soon { border-right-color: var(--amber); }
.stat-card .num { font-size: 26px; font-weight: 800; color: var(--slate-dark); }
.stat-card .label { font-size: 13px; color: #7a8a8d; margin-top: 4px; }

/* ------------------------- جدول / کارت واکنش‌گرا ------------------------- */
.section-title { font-size: 17px; font-weight: 700; color: var(--slate-dark); margin: 0 0 14px; display:flex; align-items:center; justify-content:space-between; }
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-chip {
    padding: 6px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--line);
    font-size: 13px; color: var(--slate);
}
.filter-chip.active { background: var(--teal); color: #fff; border-color: var(--teal); }

.data-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th, .data-table td { padding: 12px 14px; text-align: right; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.data-table th { background: #f0ede5; color: var(--slate); font-weight: 700; font-size: 12.5px; }
.data-table tr:last-child td { border-bottom: none; }

.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; display: inline-block; }
.badge-overdue { background: var(--red-bg); color: var(--red); }
.badge-soon { background: var(--amber-bg); color: var(--amber); }
.badge-ok { background: var(--green-bg); color: var(--green); }

.empty-state { text-align: center; padding: 40px 20px; color: #8b9a9d; background: var(--card); border-radius: var(--radius); }
.loading { padding: 40px; text-align: center; color: #8b9a9d; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.search-input {
    padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); font-family: inherit; font-size: 14px; min-width: 220px;
}

/* ------------------------- مودال ------------------------- */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(28,43,46,0.45);
    align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 420px;
    max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; color: var(--slate-dark); }
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13.5px; color: var(--slate); }
.form-field input, .form-field select {
    padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); font-family: inherit; font-size: 14px;
}
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ------------------------- پنل مشتری ------------------------- */
.customer-shell { max-width: 480px; width: 100%; }
.customer-header { text-align: center; margin-bottom: 22px; }
.customer-header h1 { font-size: 20px; color: var(--slate-dark); margin-bottom: 4px; }
.customer-header p { color: #6b7a7e; font-size: 14px; }
.customer-cards { display: flex; flex-direction: column; gap: 12px; }
.service-card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.service-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.category-tag { font-weight: 700; font-size: 14px; color: var(--slate-dark); }
.asset-label { font-size: 13px; color: #7a8a8d; margin-bottom: 6px; }
.due-date { font-size: 14px; color: var(--slate); }
.days-left { font-size: 13px; color: #7a8a8d; margin-top: 2px; }

/* ------------------------- زیرخدمات و چک‌باکس‌های درون‌خطی ------------------------- */
.subitems-row td { background: #f6f9f9; color: #6b7a7e; padding: 4px 14px !important; }
.subitem-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px; border-bottom: 1px solid #eef1f1; }
.subitem-row:last-child { border-bottom: none; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; margin-inline-end: 14px; margin-bottom: 8px; font-size: 13.5px; }
.checkbox-inline input { width: auto; }
textarea { width: 100%; padding: 10px 12px; border: 1px solid #dde3e3; border-radius: 10px; font-family: inherit; font-size: 14px; resize: vertical; }
textarea:focus { outline: none; border-color: var(--teal); }

/* ------------------------- تب‌های فرعی (مثلا وام‌ها/سپرده‌ها) ------------------------- */
.sub-tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.sub-tab-btn { background: none; border: none; padding: 10px 16px; font-family: inherit; font-size: 14px; color: #7a8a8d; cursor: pointer; border-bottom: 2px solid transparent; }
.sub-tab-btn.active { color: var(--teal-dark); border-bottom-color: var(--teal); font-weight: 700; }
.installment-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.installment-row .money-input { flex: 1; min-width: 100px; }

/* ------------------------- انتخابگر تاریخ شمسی ------------------------- */
.jalali-date-picker { display: flex; gap: 6px; }
.jalali-date-picker select { flex: 1; padding: 10px 6px; border: 1px solid #dde3e3; border-radius: 10px; font-family: inherit; font-size: 13.5px; background: #fff; }
.jalali-date-picker select:focus { outline: none; border-color: var(--teal); }
.jalali-date-picker .jdp-year { flex: 1.1; }
.jalali-date-picker .jdp-month { flex: 1.4; }
.jalali-date-picker .jdp-day { flex: 0.8; }

/* ------------------------- کارت‌های تعرفه (پنل سوپرادمین) ------------------------- */
.plan-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.plan-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* ------------------------- واکنش‌گرایی موبایل ------------------------- */
@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "content"; }
    .menu-toggle { display: block; }
    .sidebar {
        position: fixed; top: 60px; right: -240px; bottom: 0; width: 220px; z-index: 30;
        transition: right .2s ease;
    }
    .sidebar.open { right: 0; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { background: var(--card); border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow); padding: 8px 4px; }
    .data-table td {
        border: none; display: flex; justify-content: space-between; padding: 8px 14px; font-size: 13.5px;
    }
    .data-table td::before { content: attr(data-label); font-weight: 700; color: var(--slate); }
}

@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr 1fr; }
    .content { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
