@font-face {
    font-family: "Vazir";
    src:
        url("../vazir-font/Vazir.woff2") format("woff2"),
        url("../vazir-font/Vazir.woff") format("woff");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Vazir";
    src:
        url("../vazir-font/Vazir-Medium.woff2") format("woff2"),
        url("../vazir-font/Vazir-Medium.woff") format("woff");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Vazir";
    src:
        url("../vazir-font/Vazir-Bold.woff2") format("woff2"),
        url("../vazir-font/Vazir-Bold.woff") format("woff");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

:root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --primary: 221.2 83.2% 53.3%;
    --primary-foreground: 210 40% 98%;
    --destructive: 0 84.2% 60.2%;
    --ring: 221.2 83.2% 53.3%;
    --radius: 0.5rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: hsl(210 36% 97%);
    color: hsl(var(--foreground));
    direction: rtl;
    font-family: "Vazir", Tahoma, Arial, sans-serif;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.admin-shell {
    min-height: 100vh;
}

.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, hsl(221 83% 96%), hsl(210 40% 98%) 48%, hsl(24 95% 97%)),
        hsl(var(--background));
}

.auth-card {
    width: min(100%, 420px);
    display: grid;
    gap: 28px;
    padding: 32px;
    border: 1px solid hsl(var(--border));
    border-radius: 12px;
    background: hsl(var(--card));
    box-shadow: 0 24px 70px hsl(222 47% 11% / 0.13), 0 1px 2px hsl(222 47% 11% / 0.05);
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, hsl(221.2 83.2% 53.3%), hsl(199 89% 48%));
    color: hsl(var(--primary-foreground));
    font-weight: 700;
    box-shadow: 0 10px 28px hsl(221.2 83.2% 53.3% / 0.24);
}

.eyebrow {
    margin: 0 0 6px;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(1.75rem, 3vw, 2.35rem);
    line-height: 1.08;
    font-weight: 700;
}

h2 {
    margin-bottom: 4px;
    font-size: 1rem;
    line-height: 1.35;
    font-weight: 700;
}

.muted,
.card-header p,
.activity-list p,
.sidebar-brand span {
    color: hsl(var(--muted-foreground));
}

.stack {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 8px;
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    font-weight: 600;
}

.input {
    min-height: 40px;
    width: 100%;
    border: 1px solid hsl(var(--input));
    border-radius: 6px;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    padding: 9px 12px;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:focus {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.16);
}

.password-control {
    position: relative;
    display: block;
}

.password-control .input {
    padding-left: 76px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    left: 6px;
    min-width: 62px;
    min-height: 30px;
    border: 0;
    border-radius: 6px;
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    padding: 5px 9px;
    font-size: 0.78rem;
    font-weight: 700;
    transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle:focus {
    background: hsl(221.2 83.2% 95%);
    color: hsl(var(--primary));
    outline: none;
}

.button,
.icon-button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 9px 14px;
    background: transparent;
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.button-primary:hover {
    background: hsl(221.2 83.2% 47%);
}

.button-outline {
    border-color: hsl(var(--border));
    background: hsl(var(--background));
}

.button-outline:hover,
.button-ghost:hover,
.icon-button:hover {
    background: hsl(var(--muted));
}

.button-ghost {
    color: hsl(var(--muted-foreground));
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.form-error,
.form-success,
.alert {
    margin: 0;
    font-size: 0.875rem;
}

.form-error {
    color: hsl(var(--destructive));
}

.form-success {
    color: hsl(142 72% 28%);
}

.alert {
    border: 1px solid hsl(0 84% 88%);
    border-radius: var(--radius);
    background: hsl(0 84% 97%);
    padding: 12px 14px;
}

.dashboard-app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    background:
        linear-gradient(180deg, hsl(210 40% 98%), hsl(210 36% 96%)),
        hsl(var(--muted));
}

.mobile-bottom-nav {
    display: none;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid hsl(var(--border));
    background: hsl(var(--background) / 0.92);
    padding: 20px;
    backdrop-filter: blur(14px);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.sidebar-brand div:last-child {
    display: grid;
    gap: 2px;
}

.nav-list {
    display: grid;
    gap: 6px;
}

.nav-item {
    width: 100%;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: hsl(var(--muted-foreground));
    padding: 11px 12px;
    text-align: right;
    font-weight: 700;
    transition: background 120ms ease, color 120ms ease;
}

.nav-item:hover,
.nav-item.is-active {
    background: hsl(221.2 83.2% 96%);
    color: hsl(var(--foreground));
}

.main-panel {
    min-width: 0;
    display: grid;
    align-content: start;
    gap: 22px;
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid hsl(var(--border));
    border-radius: 12px;
    background: hsl(var(--background) / 0.9);
    padding: 16px 18px;
    box-shadow: 0 1px 2px hsl(222 47% 11% / 0.04);
}

.topbar-actions,
.filters {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 180px 180px;
    gap: 10px;
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(210 40% 99%);
    padding: 14px 16px;
}

.user-chip,
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border: 1px solid hsl(var(--border));
    border-radius: 999px;
    background: hsl(var(--background));
    padding: 3px 9px;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-active {
    border-color: hsl(142 56% 78%);
    background: hsl(142 76% 96%);
    color: hsl(142 72% 24%);
}

.badge-expired,
.badge-inactive {
    border-color: hsl(0 84% 88%);
    background: hsl(0 84% 97%);
    color: hsl(0 72% 36%);
}

.badge-admin {
    border-color: hsl(221 83% 84%);
    background: hsl(221 83% 97%);
    color: hsl(221 83% 34%);
}

.view {
    display: none;
}

.view.is-active {
    display: grid;
    gap: 20px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.metric-card,
.card {
    border: 1px solid hsl(var(--border));
    border-radius: 12px;
    background: hsl(var(--card));
    box-shadow: 0 12px 34px hsl(222 47% 11% / 0.06), 0 1px 2px hsl(222 47% 11% / 0.04);
}

.metric-card {
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.metric-card span {
    color: hsl(var(--muted-foreground));
    font-size: 0.8rem;
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin-top: 10px;
    font-size: 2rem;
    line-height: 1;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
    gap: 20px;
}

.users-layout {
    display: grid;
    grid-template-columns: minmax(300px, 0.38fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.create-user-card {
    position: sticky;
    top: 28px;
}

.create-user-form {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: hsl(222 47% 11% / 0.38);
    backdrop-filter: blur(6px);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal-panel {
    width: min(100%, 520px);
    max-height: min(720px, calc(100vh - 36px));
    overflow: auto;
    border: 1px solid hsl(var(--border));
    border-radius: 14px;
    background: hsl(var(--background));
    box-shadow: 0 26px 80px hsl(222 47% 11% / 0.24);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid hsl(var(--border));
    padding: 18px;
}

.modal-header p {
    margin-bottom: 0;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 2px;
}

.card {
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid hsl(var(--border));
    padding: 16px;
}

.table-header {
    align-items: center;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid hsl(var(--border));
    padding: 12px 16px;
    text-align: right;
    white-space: nowrap;
    font-size: 0.875rem;
}

th {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 700;
    background: hsl(210 40% 98%);
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: hsl(var(--muted) / 0.55);
}

.empty-row {
    color: hsl(var(--muted-foreground));
    text-align: center;
}

.activity-list {
    display: grid;
    gap: 0;
}

.activity-item {
    display: grid;
    gap: 4px;
    border-bottom: 1px solid hsl(var(--border));
    padding: 14px 16px;
}

.activity-item:last-child {
    border-bottom: 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid hsl(var(--border));
    padding: 12px 16px;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: hsl(222 47% 11% / 0.32);
}

.drawer {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    width: min(100%, 520px);
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
    border-right: 1px solid hsl(var(--border));
    background: hsl(var(--background));
    box-shadow: 20px 0 80px hsl(222 47% 11% / 0.18);
}

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid hsl(var(--border));
    padding: 18px;
}

.drawer-body {
    display: grid;
    align-content: start;
    gap: 18px;
    overflow: auto;
    padding: 18px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.detail-item {
    display: grid;
    gap: 4px;
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    padding: 12px;
}

.detail-item span {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 700;
}

.detail-item strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.icon-button {
    width: 40px;
    padding: 0;
    border-color: hsl(var(--border));
    background: hsl(var(--background));
}

[hidden] {
    display: none !important;
}

@media (max-width: 1080px) {
    .dashboard-app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 18px;
        border-right: 0;
        border-bottom: 1px solid hsl(var(--border));
    }

    .nav-list {
        grid-template-columns: repeat(3, auto);
    }

    .metric-grid,
    .content-grid,
    .users-layout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .create-user-card {
        position: static;
    }
}

@media (max-width: 720px) {
    body {
        background: hsl(210 40% 98%);
    }

    .main-panel,
    .sidebar {
        padding: 16px;
    }

    .dashboard-app {
        display: block;
        padding-bottom: 88px;
    }

    .sidebar {
        display: none;
    }

    .main-panel {
        padding: 14px 14px 0;
    }

    .topbar,
    .card-header,
    .table-header,
    .topbar-actions,
    .filters,
    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .table-toolbar {
        grid-template-columns: 1fr;
    }

    .metric-grid,
    .content-grid,
    .users-layout,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        border-radius: 14px;
        padding: 14px;
    }

    .topbar h1 {
        font-size: 1.55rem;
    }

    .metric-grid {
        gap: 10px;
    }

    .metric-card {
        padding: 14px;
    }

    .mobile-bottom-nav {
        position: fixed;
        right: 12px;
        bottom: 12px;
        left: 12px;
        z-index: 20;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        border: 1px solid hsl(var(--border));
        border-radius: 18px;
        background: hsl(var(--background) / 0.94);
        padding: 8px;
        box-shadow: 0 16px 44px hsl(222 47% 11% / 0.18);
        backdrop-filter: blur(18px);
    }

    .mobile-nav-item {
        min-height: 46px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: hsl(var(--muted-foreground));
        font-size: 0.82rem;
        font-weight: 700;
        text-align: center;
    }

    .mobile-nav-item.is-active {
        background: hsl(221.2 83.2% 96%);
        color: hsl(var(--primary));
    }

    .drawer {
        width: 100%;
    }

    .modal {
        align-items: end;
        padding: 10px;
    }

    .modal-panel {
        width: 100%;
        max-height: calc(100vh - 20px);
        border-radius: 16px;
    }

    .modal-actions {
        grid-template-columns: 1fr;
    }
}
