/* =====================================================
   پنل پیام‌بان — استایل اصلی (RTL فارسی)
   ===================================================== */

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700; font-style: normal; font-display: swap;
}

:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --green: #059669;
    --red: #dc2626;
    --amber: #d97706;
    --sidebar: #0f172a;
    --sidebar-text: #cbd5e1;
    --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Vazirmatn', Tahoma, 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: Consolas, Monaco, monospace; }

/* ---------- چیدمان ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px; flex-shrink: 0;
    background: var(--sidebar);
    color: var(--sidebar-text);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px; border-bottom: 1px solid #1e293b;
}
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff; font-weight: 700; font-size: 18px;
}
.brand-mark.big { width: 56px; height: 56px; font-size: 26px; border-radius: 14px; }
.brand-name { font-weight: 700; font-size: 16px; color: #fff; }

.menu { padding: 12px 10px; flex: 1; }
.menu a {
    display: flex; align-items: center; gap: 10px;
    color: var(--sidebar-text);
    padding: 10px 12px; border-radius: 8px;
    margin-bottom: 4px; font-size: 13.5px;
}
.menu a:hover { background: #1e293b; text-decoration: none; color: #fff; }
.menu a.active { background: var(--primary); color: #fff; }
.menu .ico { width: 20px; text-align: center; }
.badge {
    margin-inline-start: auto;
    background: #ef4444; color: #fff;
    font-size: 11px; font-weight: 700;
    border-radius: 999px; padding: 1px 8px;
}
.sidebar-foot {
    padding: 14px 20px; font-size: 11px; color: #475569;
    border-top: 1px solid #1e293b;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 28px;
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 16px; margin: 0; flex: 1; }
.hamburger { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; padding: 4px 10px; cursor: pointer; }

.user-chip { position: relative; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.user-chip:hover { background: var(--bg); }
.user-name { font-weight: 500; font-size: 13px; }
.user-role {
    background: var(--bg); color: var(--muted);
    border-radius: 999px; padding: 1px 10px; font-size: 11px;
}
.user-drop {
    display: none; position: absolute; top: 100%; left: 0; margin-top: 6px;
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    min-width: 150px; box-shadow: 0 8px 24px rgba(15,23,42,.12); overflow: hidden; z-index: 60;
}
.user-chip:hover .user-drop { display: block; }
.user-drop a { display: block; padding: 9px 14px; color: var(--text); font-size: 13px; }
.user-drop a:hover { background: var(--bg); text-decoration: none; }
.user-drop a.danger { color: var(--red); }

.content { padding: 24px 28px; max-width: 1200px; width: 100%; }

/* ---------- کارت‌ها و جدول‌ها ---------- */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px;
}
.card-head {
    font-weight: 700; font-size: 14px; margin: -18px -20px 16px;
    padding: 13px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.card-head.sub { margin: 16px -20px 12px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    text-align: right; color: var(--muted); font-weight: 500; font-size: 12px;
    padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #f8fafc; }
.row-new td { background: #eff6ff; }
.row-new:hover td { background: #e0ecff; }
.preview { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 22px 10px !important; }
.dim { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.row-actions { white-space: nowrap; }

/* ---------- دکمه‌ها و فرم‌ها ---------- */
.btn {
    display: inline-block; background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 16px; font-family: inherit; font-size: 13px;
    cursor: pointer; text-decoration: none; line-height: 1.6;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ok:hover { background: #047857; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; }

label { display: block; font-size: 13px; font-weight: 500; margin: 12px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--border); border-radius: 8px;
    font-family: inherit; font-size: 13px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.check-row { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.check-row input { width: auto; }

/* ---------- انتخاب نوع سایت ---------- */
.pb-site-type { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 4px; }
.pb-type-option {
    display: flex; align-items: flex-start; gap: 9px;
    border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 12px; cursor: pointer; margin: 0;
    transition: border-color .15s, background .15s;
}
.pb-type-option:hover { border-color: var(--primary); }
.pb-type-option:has(input:checked) { border-color: var(--primary); background: #eff6ff; }
.pb-type-option input { width: auto; margin-top: 3px; }
.pb-type-option span { display: flex; flex-direction: column; gap: 2px; }
.pb-type-option b { font-size: 13px; }
.pb-type-option small { color: #64748b; font-size: 11.5px; line-height: 1.6; }
.pb-snippet-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.inline-form { display: inline-flex; align-items: center; gap: 8px; }
.inline-form select { width: auto; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }

/* ---------- فلش / پیام‌ها ---------- */
.flash {
    border-radius: 8px; padding: 11px 16px; margin-bottom: 14px;
    font-size: 13px; border: 1px solid transparent;
}
.flash-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ---------- نشان وضعیت ---------- */
.pill {
    display: inline-block; border-radius: 999px;
    padding: 2px 12px; font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.pill-new      { background: #dbeafe; color: #1d4ed8; }
.pill-read     { background: #f1f5f9; color: #475569; }
.pill-answered { background: #d1fae5; color: #065f46; }
.pill-spam     { background: #fee2e2; color: #991b1b; }
.pill-archived { background: #fef3c7; color: #92400e; }

/* ---------- داشبورد ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; color: var(--text); transition: box-shadow .15s;
}
.stat-card:hover { text-decoration: none; box-shadow: 0 4px 16px rgba(15,23,42,.08); }
.stat-card.warn .stat-num { color: var(--red); }
.stat-num { font-size: 30px; font-weight: 700; color: var(--primary); line-height: 1.3; }
.stat-label { color: var(--muted); font-size: 12.5px; }

.panel-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
.panel-grid .card { margin-bottom: 20px; }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-bar {
    width: 70%; max-width: 34px; margin-top: auto;
    background: linear-gradient(180deg, #60a5fa, #2563eb);
    border-radius: 4px 4px 0 0; min-height: 3px;
}
.chart-day { font-size: 10px; color: var(--muted); margin-top: 6px; }

/* ---------- تب‌ها و فیلترها ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    padding: 7px 14px; font-size: 13px; color: var(--text);
    display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { text-decoration: none; background: var(--bg); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab-count { background: rgba(100,116,139,.12); border-radius: 999px; padding: 0 8px; font-size: 11px; }
.tab.active .tab-count { background: rgba(255,255,255,.25); }

.filters {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 16px;
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.filters input, .filters select { width: auto; min-width: 150px; }
.filters input[type=text] { flex: 1; min-width: 180px; }
.filters .btn-ok { margin-inline-start: auto; }

/* ---------- صفحه‌بندی ---------- */
.pb-pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pg {
    border: 1px solid var(--border); border-radius: 7px;
    padding: 4px 12px; font-size: 12.5px; color: var(--text); background: #fff;
}
.pg:hover { text-decoration: none; background: var(--bg); }
.pg.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg.dots { border: 0; background: none; }

/* ---------- جزئیات پیام ---------- */
.detail-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; align-items: start; }
.detail-grid.narrow { grid-template-columns: 1fr; max-width: 760px; }
.detail-grid .wide { grid-column: 1 / -1; }

.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv th {
    text-align: right; font-weight: 500; color: var(--muted);
    padding: 9px 12px 9px 0; width: 170px; vertical-align: top;
    border-bottom: 1px solid #f1f5f9;
}
.kv td { padding: 9px 0; border-bottom: 1px solid #f1f5f9; word-break: break-word; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }
.kv.meta th { width: 120px; }

.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { padding: 8px 0; border-bottom: 1px solid #f1f5f9; display: flex; flex-direction: column; }
.file-meta { color: var(--muted); font-size: 11.5px; }

.notes { list-style: none; margin: 0 0 12px; padding: 0; }
.notes li { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.note-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.note-body { font-size: 13px; }

.danger-zone { border-color: #fecaca; }

.token-box {
    display: flex; align-items: center; gap: 10px;
    background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px; padding: 10px 14px;
}
.token-box code { flex: 1; font-size: 11.5px; word-break: break-all; direction: ltr; text-align: left; }

.help-list { margin: 0; padding-inline-start: 20px; }
.help-list li { margin-bottom: 8px; font-size: 13.5px; }

/* ---------- صفحه ورود ---------- */
.login-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box {
    background: var(--card); border-radius: 16px; padding: 36px 34px;
    width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
    text-align: center;
}
.login-brand { display: flex; justify-content: center; margin-bottom: 14px; }
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.login-box label { text-align: right; }
.login-box button { margin-top: 18px; }

/* ---------- ریسپانسیو ---------- */
@media (max-width: 1024px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-grid, .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar { position: fixed; right: -240px; transition: right .2s; z-index: 100; }
    .sidebar.open { right: 0; box-shadow: -10px 0 40px rgba(0,0,0,.3); }
    .hamburger { display: block; }
    .content { padding: 16px; }
    .form-2col { grid-template-columns: 1fr; }
    .table { font-size: 12px; }
    .table th, .table td { padding: 7px 6px; }
}
