@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-Bold.woff2') format('woff2');
    font-weight: 700 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Black.woff2') format('woff2');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --teal: #12b8a6;
    --teal-dark: #0d9183;
    --dark: #2f3439;
    --muted: #667085;
    --line: #e6eef0;
    --bg: #f5fbfb;
    --white: #fff;
    --danger: #c0392b;
    --success: #087f5b;
    --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--dark);
}

a {
    color: inherit;
    text-decoration: none;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at top right, rgba(18, 184, 166, 0.2), transparent 38rem),
        linear-gradient(135deg, #ffffff 0%, #f0fbfa 100%);
}

.auth-card {
    width: min(1060px, 100%);
    min-height: 620px;
    display: grid;
    grid-template-columns: 1fr 440px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(18, 184, 166, 0.16);
    border-radius: 34px;
    overflow: hidden;
    box-shadow: 0 30px 100px rgba(15, 23, 42, 0.14);
}

.auth-visual {
    position: relative;
    background: linear-gradient(160deg, rgba(18, 184, 166, 0.18), rgba(255, 255, 255, 0.85));
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
}

.auth-logo {
    position: absolute;
    top: 34px;
    right: 34px;
    width: 112px;
    height: 112px;
    object-fit: cover;
    border-radius: 26px;
    box-shadow: var(--shadow);
}

.auth-assistant {
    width: 118%;
    max-width: 680px;
    filter: drop-shadow(0 28px 48px rgba(15, 23, 42, 0.2));
}

.login-form {
    padding: 54px 42px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.form-kicker {
    display: inline-flex;
    color: var(--teal-dark);
    font-weight: 900;
    margin-bottom: 8px;
}

.form-header h1 {
    margin: 0;
    font-size: 30px;
}

.form-header p {
    color: var(--muted);
    line-height: 1.9;
    margin: 12px 0 28px;
}

.field {
    display: block;
    margin-bottom: 18px;
}

.field span {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
}

.field input {
    width: 100%;
    height: 52px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0 16px;
    font: inherit;
    background: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgba(18, 184, 166, 0.14);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border-radius: 16px;
    border: 0;
    padding: 0 20px;
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    box-shadow: 0 18px 34px rgba(18, 184, 166, 0.28);
}

.btn-outline {
    border: 1px solid rgba(18, 184, 166, 0.24);
    color: var(--teal-dark);
    background: #fff;
}

.back-link {
    display: inline-flex;
    margin-top: 20px;
    color: var(--muted);
    justify-content: center;
}

.alert {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 18px;
    line-height: 1.7;
    font-weight: 700;
}

.alert-success {
    background: rgba(8, 127, 91, 0.1);
    color: var(--success);
    border: 1px solid rgba(8, 127, 91, 0.16);
}

.alert-error {
    background: rgba(192, 57, 43, 0.1);
    color: var(--danger);
    border: 1px solid rgba(192, 57, 43, 0.16);
}

.admin-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #313638;
    color: #fff;
    padding: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}

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

.brand-logo {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    object-fit: cover;
}

.brand-title {
    font-size: 18px;
    font-weight: 900;
}

.sidebar-nav {
    display: grid;
    gap: 10px;
}

.nav-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.82);
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover,
.nav-link.is-active {
    background: rgba(18, 184, 166, 0.18);
    color: #fff;
}

.nav-link.is-disabled {
    opacity: 0.62;
    cursor: not-allowed;
}

.nav-link small {
    color: rgba(255, 255, 255, 0.54);
}

.main-panel {
    padding: 24px clamp(18px, 3vw, 36px);
}

.topbar {
    min-height: 74px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}

.topbar strong,
.topbar span {
    display: block;
}

.topbar span {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 0 22px;
}

.page-heading h1 {
    margin: 0;
    font-size: 28px;
}

.page-heading p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.8;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card,
.panel-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 22px;
    box-shadow: var(--shadow);
}

.stat-card span,
.stat-card small {
    display: block;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin: 10px 0;
    font-size: 34px;
    color: var(--teal-dark);
}

.panel-card {
    margin-top: 18px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-header h2 {
    margin: 0;
    font-size: 20px;
}

.status-pill {
    color: var(--teal-dark);
    background: rgba(18, 184, 166, 0.12);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 900;
}

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

.install-checks div {
    padding: 14px;
    border-radius: 16px;
    background: #f8fafa;
    border: 1px solid var(--line);
}

.empty-state {
    color: var(--muted);
    padding: 18px;
    background: #f8fafa;
    border-radius: 18px;
    border: 1px dashed var(--line);
}

.table-wrap {
    overflow: auto;
}

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

th,
td {
    text-align: right;
    padding: 14px;
    border-bottom: 1px solid var(--line);
}

th {
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 1000px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
    }

    .stat-grid,
    .install-checks {
        grid-template-columns: repeat(2, 1fr);
    }

    .auth-card {
        grid-template-columns: 1fr;
    }

    .auth-visual {
        min-height: 280px;
    }
}

@media (max-width: 640px) {
    .auth-body {
        padding: 12px;
    }

    .login-form {
        padding: 32px 22px;
    }

    .stat-grid,
    .install-checks {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Phase 2: admin modules */
.topbar-actions,
.heading-actions,
.form-actions,
.filter-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.heading-actions {
    justify-content: flex-end;
}

.btn-small {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 13px;
}

.btn-danger {
    color: #fff;
    background: var(--danger);
}

.btn-ghost {
    color: var(--muted);
    background: transparent;
}

button:disabled,
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.soft-card,
.hint-card {
    background: linear-gradient(135deg, #ffffff, #f1fbfa);
    line-height: 1.9;
}

.hint-card a,
.link-accent,
.table-title,
.stat-card a {
    color: var(--teal-dark);
    font-weight: 900;
}

.filter-bar {
    display: grid;
    grid-template-columns: 1fr 220px auto;
    gap: 14px;
    align-items: end;
}

.filter-bar-wide {
    grid-template-columns: 1fr 240px 180px auto;
}

.filter-bar label,
.admin-form .field {
    display: block;
    margin: 0;
}

.filter-bar span,
.admin-form .field span {
    display: block;
    margin-bottom: 8px;
    color: var(--dark);
    font-weight: 900;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0 14px;
    font: inherit;
    color: var(--dark);
    background: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input,
select {
    min-height: 48px;
}

textarea {
    padding-top: 14px;
    padding-bottom: 14px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgba(18, 184, 166, 0.14);
}

.field small,
.muted-line {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
    margin-top: 7px;
}

.form-card {
    max-width: 1120px;
}

.admin-form {
    display: grid;
    gap: 22px;
}

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

.field-full {
    grid-column: 1 / -1;
}

.data-table th,
.data-table td {
    vertical-align: middle;
}

.data-table code {
    direction: ltr;
    display: inline-flex;
    background: #f4f6f8;
    border: 1px solid var(--line);
    padding: 4px 8px;
    border-radius: 10px;
    color: #475467;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.badge-success {
    color: var(--success);
    background: rgba(8, 127, 91, 0.1);
    border: 1px solid rgba(8, 127, 91, 0.18);
}

.badge-muted {
    color: #6c757d;
    background: #f1f3f5;
    border: 1px solid #e9ecef;
}

.video-table th:first-child,
.video-table td:first-child {
    width: 96px;
}

.cover-thumb,
.cover-preview {
    width: 78px;
    height: 58px;
    display: block;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #f8fafa;
}

.cover-preview {
    width: 220px;
    height: 140px;
    margin-bottom: 10px;
}

.cover-placeholder {
    width: 78px;
    height: 58px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 6px;
    color: var(--muted);
    background: #f8fafa;
    border: 1px dashed var(--line);
    border-radius: 14px;
    font-size: 11px;
}

.token-text {
    direction: ltr;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.danger-text {
    color: var(--danger);
}

.link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: linear-gradient(135deg, rgba(18, 184, 166, 0.09), #fff);
}

.link-card p {
    direction: ltr;
    text-align: left;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    margin: 10px 0 6px;
    word-break: break-all;
}

.summary-box {
    min-height: 58px;
    display: grid;
    align-content: center;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 14px;
    background: #f8fafa;
}

.check-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: var(--muted);
    font-weight: 700;
}

.check-line input {
    width: auto;
    min-height: auto;
}

.copy-toast {
    position: fixed;
    left: 22px;
    bottom: 22px;
    z-index: 1000;
    background: #313638;
    color: #fff;
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: var(--shadow);
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.2s ease;
}

.copy-toast.is-visible {
    transform: translateY(0);
    opacity: 1;
}

@media (max-width: 1200px) {
    .filter-bar,
    .filter-bar-wide {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 760px) {
    .page-heading,
    .link-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .filter-bar,
    .filter-bar-wide,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .row-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .row-actions .btn,
    .row-actions form,
    .row-actions button {
        width: 100%;
    }
}

/* Phase 3: reports and production polish */
.report-filter {
    grid-template-columns: 1.2fr 1.6fr 0.9fr 0.9fr auto;
}

.report-table th,
.report-table td {
    vertical-align: top;
}

.ltr-cell {
    direction: ltr;
    text-align: left;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.user-agent-text {
    display: block;
    max-width: 430px;
    direction: ltr;
    text-align: left;
    color: var(--muted);
    line-height: 1.7;
    word-break: break-word;
}

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

.stats-row .summary-box strong {
    font-size: 24px;
}

@media (max-width: 1200px) {
    .report-filter {
        grid-template-columns: 1fr 1fr;
    }
}

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

/* Phase 4 additions: users, permissions, center links, upload links */
.badge-warning{background:#fff7db;color:#8a5a00;border:1px solid #ffe1a3}
.badge-danger-soft{background:#ffe8e8;color:#a32323;border:1px solid #ffc7c7}
.badge-info{background:#e8f6ff;color:#0b6b96;border:1px solid #cdeeff}
.permission-box{margin-top:22px;border:1px solid #e8eef1;border-radius:18px;padding:18px;background:#fbfefe}
.permission-box h3{margin:0 0 6px;font-size:18px;color:#253238}
.permission-table td,.permission-table th{text-align:center}.permission-table td:first-child,.permission-table th:first-child{text-align:right}
.permission-table input[type="checkbox"]{width:18px;height:18px;accent-color:#12b8a6}
.stats-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:14px}.summary-box{padding:16px;border-radius:16px;background:#f7fbfb;border:1px solid #e4eeee}.summary-box strong{display:block;font-size:22px;color:#153b42}.summary-box span{display:block;margin-top:6px;color:#60727a;font-size:13px}
.row-actions .btn-primary{padding:7px 10px}.filter-bar-wide{grid-template-columns:repeat(auto-fit,minmax(170px,1fr))}.danger-text{color:#b3261e!important}
@media(max-width:900px){.permission-table{min-width:760px}.sidebar-nav .nav-link{font-size:13px}}

/* Patch 05: Production workflow */
.checkbox-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px;margin-top:14px}.check-card{display:flex;flex-direction:column;gap:4px;border:1px solid #e1efee;border-radius:14px;padding:12px;background:#fbfffe}.check-card input{margin-left:8px}.check-card span{font-weight:800}.check-card small{color:#6c7c7a;direction:ltr;text-align:left}.full-field{display:block;margin-top:18px}.two-col-grid{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(280px,.8fr);gap:18px}.timeline{display:flex;flex-direction:column;gap:12px}.timeline-item{position:relative;border-right:3px solid #12b8a6;background:#fbfffe;border-radius:14px;padding:12px 16px}.timeline-item strong{display:block;color:#243332}.timeline-item span{display:block;color:#748481;font-size:12px;margin-top:3px}.timeline-item p{margin:8px 0 0;line-height:1.9}.compact-log{margin:8px 0 20px;padding-right:18px;color:#536361;line-height:2}.subheading{font-size:15px;margin:18px 0 6px}.production-summary .stat-card strong{font-size:18px}.success-card{border-color:#bfeadb;background:#f7fffb}.stacked-actions{align-items:flex-start;gap:8px}.mini-review-form{display:flex;flex-direction:column;gap:6px;min-width:220px}.mini-review-form textarea{border:1px solid #d9e8e6;border-radius:10px;padding:8px;resize:vertical;font-family:inherit}.ltr-cell{direction:ltr;text-align:left}.badge-danger-soft{background:#ffe8e8;color:#a32323;border:1px solid #ffc7c7}.badge-warning{background:#fff7db;color:#8a5a00;border:1px solid #ffe1a3}.badge-info{background:#e8f6ff;color:#0b6b96;border:1px solid #cdeeff}@media(max-width:900px){.two-col-grid{grid-template-columns:1fr}.mini-review-form{min-width:0}}

/* Patch 06: local Vazirmatn, stronger mobile layout, Jalali calendar */
html {
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

body,
button,
input,
select,
textarea {
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
}

input[data-jalali-date],
input[data-jalali-datetime] {
    direction: ltr;
    text-align: right;
}

.jalali-picker {
    position: fixed;
    z-index: 5000;
    width: 302px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
    padding: 12px;
    direction: rtl;
}

.jalali-picker[hidden] {
    display: none !important;
}

.jalali-picker__head,
.jalali-picker__time,
.jalali-picker__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jalali-picker__head {
    justify-content: space-between;
    margin-bottom: 10px;
}

.jalali-picker__title {
    font-weight: 900;
    color: var(--dark);
}

.jalali-picker__nav,
.jalali-picker__today,
.jalali-picker__clear {
    border: 1px solid var(--line);
    border-radius: 12px;
    min-height: 34px;
    padding: 0 10px;
    background: #fff;
    color: var(--dark);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.jalali-picker__week,
.jalali-picker__days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.jalali-picker__week span {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    padding: 6px 0;
}

.jalali-picker__day {
    min-height: 34px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: #f8fbfb;
    color: var(--dark);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.jalali-picker__day:hover,
.jalali-picker__day.is-selected {
    background: rgba(18, 184, 166, 0.12);
    border-color: rgba(18, 184, 166, 0.28);
    color: var(--teal-dark);
}

.jalali-picker__day.is-today {
    box-shadow: inset 0 0 0 2px rgba(18, 184, 166, 0.35);
}

.jalali-picker__day.is-empty {
    visibility: hidden;
}

.jalali-picker__time {
    margin-top: 12px;
    justify-content: space-between;
}

.jalali-picker__time label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.jalali-picker__time input {
    width: 112px;
    min-height: 36px;
    border-radius: 12px;
    direction: ltr;
    text-align: center;
}

.jalali-picker__actions {
    justify-content: space-between;
    margin-top: 12px;
}

@media (max-width: 900px) {
    .admin-shell {
        display: block;
    }

    .sidebar {
        position: relative;
        height: auto;
        padding: 14px;
        border-radius: 0 0 26px 26px;
    }

    .brand-box {
        margin-bottom: 14px;
    }

    .brand-logo {
        width: 46px;
        height: 46px;
        border-radius: 14px;
    }

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

    .nav-link {
        min-height: 44px;
        padding: 10px 12px;
        border-radius: 13px;
        justify-content: center;
        text-align: center;
        font-size: 13px;
    }

    .main-panel {
        padding: 16px 12px 28px;
    }

    .topbar {
        border-radius: 20px;
        padding: 12px;
    }

    .page-heading {
        gap: 14px;
    }

    .panel-card,
    .stat-card {
        border-radius: 20px;
        padding: 16px;
    }

    .table-wrap,
    .public-table-wrap,
    .permission-box {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table,
    .report-table,
    .permission-table,
    .video-table {
        min-width: 760px;
    }
}

@media (max-width: 640px) {
    .auth-card {
        min-height: auto;
        border-radius: 24px;
    }

    .auth-visual {
        display: none;
    }

    .form-header h1,
    .page-heading h1 {
        font-size: 22px;
    }

    .sidebar-nav {
        grid-template-columns: 1fr 1fr;
    }

    .topbar-actions,
    .heading-actions,
    .form-actions,
    .filter-actions {
        width: 100%;
        align-items: stretch;
    }

    .topbar-actions .btn,
    .heading-actions .btn,
    .form-actions .btn,
    .filter-actions .btn,
    .form-actions button,
    .filter-actions button {
        width: 100%;
    }

    .filter-bar,
    .filter-bar-wide,
    .report-filter,
    .form-grid,
    .two-col-grid,
    .stats-row,
    .stat-grid,
    .install-checks {
        grid-template-columns: 1fr !important;
    }

    input,
    select,
    textarea,
    .btn {
        font-size: 16px;
    }

    .cover-preview {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 10;
    }

    .link-card p {
        width: 100%;
        text-align: left;
    }

    .copy-toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        text-align: center;
    }

    .jalali-picker {
        left: 12px !important;
        right: 12px !important;
        top: auto !important;
        bottom: 12px !important;
        width: auto;
    }
}
