/* =========================================================
   NEXO Development — admin panel
   ========================================================= */
:root {
    --navy: #00326F; --yellow: #F7A823; --orange: #EE7A1E;
    --bg: #F4F6FB; --surface: #FFFFFF; --surface-2: #F1F4FA; --text: #0B1B3A; --muted: #66728C;
    --line: rgba(0, 50, 111, .1); --logo: #00326F; --side: #00326F; --side-text: #C9D7EE;
    --shadow: 0 18px 40px -26px rgba(0, 50, 111, .35);
    --font: 'Plus Jakarta Sans', 'Vazirmatn', system-ui, sans-serif;
    --accent: #00326F; --accent-rgb: 0, 50, 111; --on-accent: #FFFFFF; --icon-a: #2F7DE1; --icon-b: #9CC3F2;
    --grad: linear-gradient(135deg, #1E64C8 0%, #00326F 60%, #001F47 100%);
    color-scheme: light;
}
[data-theme="dark"] {
    --bg: #00326F; --surface: #083E80; --surface-2: #0A4589; --text: #FFFFFF; --muted: #A8C0E2;
    --line: rgba(255, 255, 255, .12); --logo: #FFFFFF; --side: #00224D;
    --shadow: 0 18px 40px -26px rgba(0, 0, 0, .6);
    --accent: #F7A823; --accent-rgb: 247, 168, 35; --on-accent: #00326F; --icon-a: #F7A823; --icon-b: #EE7A1E;
    --grad: linear-gradient(135deg, #FFC94D, #F7A823 55%, #EE7A1E);
    color-scheme: dark;
}
html[dir="rtl"] { --font: 'Vazirmatn', 'Plus Jakarta Sans', system-ui, sans-serif; }
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; transition: background .4s, color .4s; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); font-weight: 500; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 12px; font-weight: 700; transition: transform .2s, box-shadow .2s, background .2s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--grad); color: var(--on-accent); box-shadow: 0 10px 24px -12px rgba(var(--accent-rgb), .9); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--line); }
.btn-danger { background: rgba(239, 68, 68, .12); color: #E11D48; }
[data-theme="dark"] .btn-danger { color: #FDA4AF; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn { height: 40px; min-width: 40px; padding: 0 10px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.i-sun, [data-theme="dark"] .i-moon { display: none; }
[data-theme="dark"] .i-sun { display: inline-flex; color: var(--yellow); }

.ic-a { fill: var(--icon-a); } .ic-b { fill: var(--icon-b); }
.sidebar .ic-a { fill: #6FA8F0; } .sidebar .ic-b { fill: #BFD7F5; } .ic-c { fill: currentColor; }
.svc-icon { width: 22px; height: 22px; flex: none; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; flex: none; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; transition: transform .35s; z-index: 50; }
.side-brand { color: #fff; padding: 4px 10px 24px; }
.side-logo { height: 46px; width: auto; direction: ltr; }
.login-art-logo { direction: ltr; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; font-weight: 600; transition: background .2s, color .2s; }
.sidebar nav a .ic-c { fill: #fff; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar nav a.active { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: inset 3px 0 0 #6FA8F0; }
html[dir="rtl"] .sidebar nav a.active { box-shadow: inset -3px 0 0 #6FA8F0; }
.badge { margin-inline-start: auto; background: #fff; color: var(--navy); font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.side-logout { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; color: #FCA5A5; font-weight: 600; }
.side-logout:hover { background: rgba(255, 255, 255, .06); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 16px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 40; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 21px; font-weight: 800; flex: 1; }
.top-tools { display: flex; gap: 8px; align-items: center; }
.user-chip { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--navy); color: #fff; font-weight: 800; }
[data-theme="dark"] .user-chip { background: var(--accent); color: var(--on-accent); }
.menu-toggle { display: none; }
.content { padding: 28px; display: grid; gap: 22px; align-content: start; }

/* ---------- alerts ---------- */
.alert { padding: 13px 16px; border-radius: 12px; font-weight: 600; }
.alert a { text-decoration: underline; margin-inline-start: 8px; }
.alert-success { background: rgba(34, 197, 94, .13); color: #15803D; }
.alert-error { background: rgba(239, 68, 68, .13); color: #DC2626; }
.alert-warn { background: rgba(247, 168, 35, .18); color: #92400E; }
[data-theme="dark"] .alert-success { color: #86EFAC; }
[data-theme="dark"] .alert-error { color: #FCA5A5; }
[data-theme="dark"] .alert-warn { color: #FDE68A; }

/* ---------- dashboard ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: flex; gap: 14px; align-items: center; transition: transform .25s, box-shadow .25s; }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-card .svc-icon { width: 40px; height: 40px; color: var(--navy); }
[data-theme="dark"] .stat-card .svc-icon { color: #fff; }
.stat-card strong { font-size: 26px; font-weight: 800; display: block; line-height: 1.1; }
.stat-card strong small { font-size: 14px; color: var(--muted); }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-card.hl { background: var(--grad); color: var(--on-accent); border: 0; }
.stat-card.hl span, .stat-card.hl small { color: var(--on-accent) !important; opacity: .8; }
.stat-card.hl .svc-icon { color: var(--on-accent) !important; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.msg-layout { grid-template-columns: 1fr 1.4fr; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-head h2 { font-size: 18px; font-weight: 800; }
.link { color: var(--accent); font-weight: 700; font-size: 14px; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }
.empty.big { display: grid; place-items: center; gap: 10px; padding: 70px 0; }
.empty.big .svc-icon { width: 60px; height: 60px; opacity: .5; }
.quick { display: flex; flex-wrap: wrap; gap: 10px; }
.quick-btn { padding: 11px 16px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line); font-weight: 700; font-size: 14px; transition: border-color .2s, background .2s; }
.quick-btn:hover { border-color: var(--accent); background: rgba(var(--accent-rgb), .08); }

.msg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.msg-list a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; transition: background .2s; }
.msg-list a:hover, .msg-list li.current a { background: var(--surface-2); }
.msg-list div { flex: 1; min-width: 0; }
.msg-list strong { display: block; font-size: 14px; }
.msg-list small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-list time { font-size: 12px; color: var(--muted); }
.msg-list li.unread strong::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-inline-start: 8px; vertical-align: middle; }
.avatar { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; background: var(--navy); color: #fff; font-weight: 800; }
[data-theme="dark"] .avatar { background: var(--accent); color: var(--on-accent); }
.msg-meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 18px; font-size: 14px; }
.msg-meta dt { color: var(--muted); font-weight: 700; }
.msg-meta dd { margin: 0; }
.msg-meta a { color: var(--accent); }
.msg-body { background: var(--surface-2); padding: 18px; border-radius: 14px; line-height: 1.8; margin-bottom: 18px; white-space: normal; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
html[dir="rtl"] .table th { letter-spacing: 0; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--surface-2); }
.table .svc-icon { width: 30px; height: 30px; color: var(--navy); }
[data-theme="dark"] .table .svc-icon { color: #fff; }
.t-end { text-align: end; white-space: nowrap; }
.inline { display: inline; }
.thumb { display: block; width: 64px; height: 44px; border-radius: 8px; background-size: cover; background-position: center; background-color: var(--surface-2); }
.stars { color: var(--accent); letter-spacing: 2px; }
.pill { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.on { background: rgba(34, 197, 94, .14); color: #16A34A; }
.pill.off { background: var(--surface-2); color: var(--muted); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid.one { grid-template-columns: 1fr; }
.f-row { display: flex; flex-direction: column; gap: 7px; }
.f-row.wide { grid-column: 1 / -1; }
.f-title { font-weight: 700; font-size: 13.5px; }
.f-title b { color: #E11D48; }
.f-row input[type=text], .f-row input[type=number], .f-row input[type=password], .f-row select, .f-row textarea,
.f-label input {
    width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; outline: none; transition: border-color .2s, box-shadow .2s;
}
.f-row textarea { resize: vertical; line-height: 1.7; }
.f-row input:focus, .f-row select:focus, .f-row textarea:focus, .f-label input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .15); }
.f-row.has-error input, .f-row.has-error textarea { border-color: #EF4444; }
.err { color: #EF4444; font-weight: 600; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.form-panel.narrow { max-width: 560px; }
.settings-form { display: grid; gap: 22px; }
.sticky-save { position: sticky; bottom: 16px; display: flex; justify-content: flex-end; }
.sticky-save .btn { padding: 14px 34px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

.icon-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.icon-pick input { position: absolute; opacity: 0; pointer-events: none; }
.icon-pick span { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2); cursor: pointer; transition: .2s; color: var(--navy); }
[data-theme="dark"] .icon-pick span { color: #fff; }
.icon-pick .svc-icon { width: 34px; height: 34px; }
.icon-pick input:checked + span { border-color: var(--accent); background: rgba(var(--accent-rgb), .1); transform: scale(1.06); }

.switch { position: relative; width: 52px; height: 30px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 30px; background: var(--line); cursor: pointer; transition: .25s; }
.switch span::after { content: ""; position: absolute; top: 4px; inset-inline-start: 4px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: .25s; }
.switch input:checked + span { background: var(--grad); }
.switch input:checked + span::after { inset-inline-start: 26px; }

.img-field { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.img-preview { width: 180px; height: 120px; border-radius: 14px; background: var(--surface-2) center / cover no-repeat; border: 2px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 32px; }
.img-field input[type=file] { font: inherit; font-size: 14px; }

/* ---------- confirm modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0, 20, 50, .5); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 200; padding: 16px; animation: fadeIn .2s; }
.modal { background: var(--surface); border-radius: 20px; padding: 26px; max-width: 380px; width: 100%; box-shadow: var(--shadow); text-align: center; animation: pop .25s; }
.modal p { font-weight: 700; font-size: 16px; margin: 0 0 20px; }
.modal div { display: flex; gap: 10px; justify-content: center; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; background: var(--navy); color: #fff; overflow: hidden; display: grid; place-items: center; }
.login-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px); background-size: 32px 32px; }
.login-art-logo { position: relative; width: min(340px, 60%); height: auto; z-index: 2; }
.login-blocks { position: absolute; bottom: 0; inset-inline-start: 50%; transform: translateX(-50%); display: grid; grid-template-columns: repeat(8, 26px); gap: 4px; direction: ltr; }
html[dir="rtl"] .login-blocks { transform: translateX(50%); }
.login-blocks i { width: 26px; height: 26px; border-radius: 5px; background: rgba(255, 255, 255, .14); opacity: 0; animation: block .6s forwards; animation-delay: var(--d); }
.login-blocks i:nth-child(7n) { background: var(--yellow); }
@keyframes block { from { opacity: 0; transform: translateY(-40px); } to { opacity: 1; transform: none; } }
.login-box { position: relative; display: grid; place-items: center; padding: 30px 16px; }
.login-tools { position: absolute; top: 18px; inset-inline-end: 18px; display: flex; gap: 8px; }
.login-form { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.login-logo { color: var(--logo); }
.login-form h1 { font-size: 30px; font-weight: 800; }
.login-form .muted { margin: -8px 0 4px; }
.f-label { display: grid; gap: 7px; font-weight: 700; font-size: 13.5px; }
.back-link { text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
    .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(-100%); }
    html[dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: none !important; box-shadow: 0 0 60px rgba(0, 0, 0, .4); }
    .menu-toggle { display: inline-flex; }
    .grid-2, .msg-layout { grid-template-columns: 1fr; }
    .login-page { grid-template-columns: 1fr; }
    .login-art { display: none; }
}
@media (max-width: 640px) {
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; }
    .topbar .btn-ghost, .user-chip { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .table thead { display: none; }
    .table tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
    .table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 6px 4px; }
    .table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; }
    .t-end { justify-content: flex-end !important; }
}

/* ---------- gallery field + extras ---------- */
.gallery-field { display: flex; flex-wrap: wrap; gap: 12px; }
.g-item, .g-add { position: relative; width: 120px; height: 90px; border-radius: 12px; overflow: hidden; cursor: pointer; }
.g-item span { position: absolute; inset: 0; background: var(--surface-2) center / cover no-repeat; transition: filter .2s, opacity .2s; }
.g-item input { position: absolute; opacity: 0; }
.g-item i { position: absolute; inset-inline: 6px; bottom: 6px; font-style: normal; font-size: 11px; font-weight: 700; text-align: center; padding: 3px 6px; border-radius: 8px; background: rgba(0, 0, 0, .55); color: #fff; opacity: 0; transition: opacity .2s; }
.g-item:hover i, .g-item.del i { opacity: 1; }
.g-item.del span { filter: grayscale(1); opacity: .35; }
.g-item.del i { background: #DC2626; }
.g-add { display: grid; place-items: center; border: 2px dashed var(--line); color: var(--muted); font-size: 32px; background: var(--surface-2); }
.g-add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.g-new { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.g-new span { width: 80px; height: 60px; border-radius: 8px; background: center / cover no-repeat; outline: 2px solid #22C55E; }
.chk { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.thumb.empty { background-image: repeating-linear-gradient(45deg, transparent 0 6px, var(--line) 6px 7px); }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); white-space: nowrap; }
