/* Sarafkhane Admin Panel — dark + gold */

:root {
    --bg: #0f0f10;
    --bg-2: #18181b;
    --surface: #1e1e22;
    --surface-2: #26262b;
    --border: #2a2a30;
    --border-strong: #3a3a42;
    --text: #f5f5f7;
    --text-muted: #a1a1aa;
    --text-dim: #71717a;
    --gold: #f5b942;
    --gold-2: #facc6b;
    --gold-soft: rgba(245, 185, 66, 0.12);
    --gold-ring: rgba(245, 185, 66, 0.35);
    --danger: #ef4444;
    --success: #22c55e;
    --info: #3b82f6;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul, ol { list-style: none; }
input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ================ Layout ================ */

.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-2);
    border-inline-start: 1px solid var(--border);
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--gold), var(--gold-2));
    color: #1a1500;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
}

.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand small { color: var(--text-dim); font-size: 11px; }

.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: 10px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 180ms ease;
}

.sidebar-nav a:hover {
    background: var(--surface);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--gold-soft);
    color: var(--gold);
}

.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--border); }

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    color: #fca5a5;
    transition: all 180ms ease;
}
.logout-btn:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.main {
    padding: 24px 32px 48px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.page-title { font-size: 22px; font-weight: 700; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--gold-2));
    color: #1a1500;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-meta strong { display: block; font-size: 13px; }
.user-meta small { color: var(--text-dim); font-size: 11px; }

/* ================ Cards / Sections ================ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.card-head h2 { font-size: 18px; font-weight: 700; }
.card-head .sub { color: var(--text-dim); font-size: 13px; }

/* ================ Buttons ================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
    transition: all 180ms ease;
    white-space: nowrap;
}
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-2));
    color: #1a1500;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px -4px var(--gold-ring); }

.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--border-strong); }

.btn-danger { background: rgba(239,68,68,0.12); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,0.2); color: #fff; }

.btn-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }

/* ================ Stats grid ================ */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
}

.stat-icon {
    position: absolute;
    inset-inline-end: 16px;
    top: 16px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--gold-soft);
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-label { color: var(--text-dim); font-size: 12px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }

/* ================ Forms ================ */

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 6px;
}

.field input, .field select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-2);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    transition: all 180ms ease;
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

.field .hint { color: var(--text-dim); font-size: 11px; margin-top: 4px; }
.field.error input, .field.error select { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* Checkbox */
.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}
.checkbox input { width: 18px; height: 18px; accent-color: var(--gold); }

/* ================ Filters bar ================ */

.filters {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
    background: var(--bg-2);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.filters .field { margin-bottom: 0; }

/* ================ Table ================ */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table {
    font-size: 13px;
}

.table th {
    text-align: start;
    padding: 14px 16px;
    background: var(--bg-2);
    color: var(--text-dim);
    font-weight: 500;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-2); }

.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: rgba(34,197,94,0.12); color: #86efac; }
.badge-muted { background: var(--surface-2); color: var(--text-dim); }
.badge-gold { background: var(--gold-soft); color: var(--gold); }

/* Row actions */
.row-actions { display: flex; gap: 6px; }
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 180ms ease;
}
.icon-btn:hover { background: var(--border-strong); color: var(--text); }
.icon-btn.danger:hover { background: rgba(239,68,68,0.2); color: var(--danger); }

/* ================ Pagination ================ */

.pagination-wrap {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
}
.pagination-wrap nav { display: flex; gap: 6px; flex-wrap: wrap; }
.pagination-wrap a, .pagination-wrap span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 13px;
    transition: all 180ms ease;
}
.pagination-wrap a:hover { background: var(--border-strong); color: var(--text); }
.pagination-wrap .active span, .pagination-wrap span[aria-current] {
    background: var(--gold);
    color: #1a1500;
}

/* ================ Alerts ================ */

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
}
.alert ul { margin: 0; padding-inline-start: 18px; list-style: disc; }
.alert-success { background: rgba(34,197,94,0.1); color: #86efac; border: 1px solid rgba(34,197,94,0.25); }
.alert-error { background: rgba(239,68,68,0.1); color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }

/* ================ Empty state ================ */

.empty {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-dim);
}
.empty svg { margin: 0 auto 14px; opacity: 0.5; }
.empty h3 { color: var(--text); font-size: 17px; margin-bottom: 6px; }

/* ================ Login page ================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-image:
        radial-gradient(circle at 10% 0%, rgba(245, 185, 66, 0.1), transparent 40%),
        radial-gradient(circle at 90% 100%, rgba(245, 185, 66, 0.06), transparent 40%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 24px 60px -20px rgba(0,0,0,0.5);
}

.login-head {
    text-align: center;
    margin-bottom: 28px;
}
.login-head .brand-mark {
    margin: 0 auto 16px;
    width: 56px;
    height: 56px;
    font-size: 28px;
    border-radius: 14px;
}
.login-head h1 { font-size: 22px; margin-bottom: 6px; }
.login-head p { color: var(--text-dim); font-size: 13px; }

/* ================ Mini chart ================ */

.chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 140px;
    padding: 12px 4px 0;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(to top, var(--gold-soft), var(--gold));
    border-radius: 6px 6px 0 0;
    position: relative;
    min-height: 4px;
    transition: all 220ms ease;
    cursor: default;
}
.chart-bar:hover { filter: brightness(1.2); }
.chart-bar::after {
    content: attr(data-label);
    position: absolute;
    bottom: -22px;
    inset-inline-start: 50%;
    transform: translateX(50%);
    font-size: 11px;
    color: var(--text-dim);
}
.chart-bar::before {
    content: attr(data-count);
    position: absolute;
    top: -22px;
    inset-inline-start: 50%;
    transform: translateX(50%);
    font-size: 11px;
    color: var(--text);
    font-weight: 600;
    opacity: 0;
    transition: opacity 180ms;
}
.chart-bar:hover::before { opacity: 1; }

.chart-wrap { padding-bottom: 28px; padding-top: 28px; }

/* ================ Responsive ================ */

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 12px;
        gap: 8px;
    }
    .sidebar-brand { margin: 0; padding: 0 8px; border: none; flex: 1; }
    .sidebar-nav { flex-direction: row; flex: 1 0 100%; overflow-x: auto; }
    .sidebar-foot { border: none; padding: 0; }
    .main { padding: 16px; }
    .filters { grid-template-columns: 1fr 1fr; }
    .table th, .table td { padding: 10px 12px; }
    .table-wrap { overflow-x: auto; }
    .table { min-width: 700px; }
}

@media (max-width: 540px) {
    .login-card { padding: 28px 20px; }
    .filters { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
}
