@import url('fonts-vazir.css');

:root {
    color-scheme: light;
    --font-vazir: 'Vazirmatn', Tahoma, 'Segoe UI', system-ui, sans-serif;
    --font-yekan: var(--font-vazir);
    --color-primary: #0b3d5c;
    --color-primary-hover: #0a5278;
    --color-primary-soft: #e8f1f6;
    --color-accent: #c2410c;
    --color-accent-hover: #9a3412;
    --color-bg: #e4eaf2;
    --color-surface: #ffffff;
    --color-surface-elevated: #f8fafc;
    --panel-card-bg: #ffffff;
    --color-border: #7dcdc4;
    --color-border-subtle: #b5e4df;
    --color-text: #0f172a;
    --color-text-strong: #020617;
    --color-muted: #475569;
    --color-on-primary: #ffffff;
    --color-success-bg: #ecfdf5;
    --color-success-text: #065f46;
    --color-success-border: #34d399;
    --color-danger-bg: #fef2f2;
    --color-danger-text: #7f1d1d;
    --color-danger-border: #f87171;
    --color-warning-bg: #fffbeb;
    --color-warning-text: #78350f;
    --color-warning-border: #fbbf24;
    --color-status-done-bg: #ecfdf5;
    --color-status-done-text: #047857;
    --color-status-reject-bg: #fef2f2;
    --color-status-reject-text: #b91c1c;
    --body-grad-1: #d4dce6;
    --body-grad-2: #d4dce6;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(15, 118, 110, 0.07);
    --shadow-card: 0 8px 32px rgba(15, 118, 110, 0.09);
    --shadow-float: 0 16px 40px rgba(15, 118, 110, 0.11), 0 6px 16px rgba(15, 118, 110, 0.06);
    --portal-bottom-h: 4.25rem;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --container: 72rem;
    --header-h: 4rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    font-family: var(--font-vazir);
    line-height: 1.65;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    hanging-punctuation: first last;
}

body,
input,
select,
textarea,
button,
table,
th,
td,
label,
h1, h2, h3, h4, h5, h6 {
    font-family: inherit;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: clamp(0.9375rem, 0.9rem + 0.15vw, 1rem);
}

html[data-theme="light"] {
    color-scheme: light;
}

html[data-theme="light"] body {
    background: var(--color-bg);
    color: var(--color-text);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--color-text-strong);
    line-height: 1.35;
}

a {
    color: var(--color-primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
a:hover { color: var(--color-primary-hover); }

img { max-width: 100%; height: auto; }

.container {
    width: min(100% - 2rem, var(--container));
    margin-inline: auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: var(--header-h);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    color: inherit;
}
.brand__logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}
.brand__title {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.3;
}
.brand__sub {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.nav-toggle { display: none; }

.site-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.site-nav a {
    text-decoration: none;
    color: var(--color-text);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}
.site-nav a:not(.btn):hover {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.btn--primary {
    background: var(--color-primary);
    color: var(--color-on-primary);
}
.btn--primary:hover {
    background: var(--color-primary-hover);
    color: var(--color-on-primary);
}
.btn--accent {
    background: var(--color-accent);
    color: #fff;
}
.btn--accent:hover { background: var(--color-accent-hover); color: #fff; }
.btn--outline {
    background: transparent;
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
}
.btn--outline:hover {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

@media (max-width: 768px) {
    .nav-toggle {
        display: none;
    }
    .site-nav {
        display: none !important;
    }
    .site-nav .theme-toggle {
        display: none;
    }
    .site-header {
        position: sticky;
        top: 0;
    }
    .site-main {
        padding-bottom: calc(var(--portal-bottom-h) + env(safe-area-inset-bottom, 0px) + var(--space-4));
    }
    .site-footer {
        padding-bottom: calc(var(--portal-bottom-h) + env(safe-area-inset-bottom, 0px));
    }
    .container {
        width: min(100% - 1.25rem, var(--container));
    }
    .hero {
        padding: var(--space-6);
        margin-bottom: var(--space-6);
    }
    .hero__actions .btn {
        flex: 1 1 100%;
        justify-content: center;
    }
    .service-grid {
        grid-template-columns: 1fr;
    }
    .layout-split {
        grid-template-columns: 1fr;
    }
}

/* Portal bottom navigation */
.portal-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .portal-bottom-nav {
        display: flex;
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 100;
        min-height: var(--portal-bottom-h);
        padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
        background: var(--color-surface);
        border-top: 1px solid var(--color-border);
        box-shadow: 0 -4px 16px rgba(11, 61, 92, 0.08);
        justify-content: space-around;
        align-items: stretch;
    }

    .portal-bottom-nav__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        min-height: 44px;
        padding: 0.2rem;
        text-decoration: none;
        color: var(--color-muted);
        font-size: 0.65rem;
        font-weight: 600;
        border-radius: var(--radius-md);
    }

    .portal-bottom-nav__item svg {
        width: 22px;
        height: 22px;
    }

    .portal-bottom-nav__item.is-active {
        color: var(--color-primary);
        background: var(--color-primary-soft);
    }
}

@media (min-width: 769px) {
    .portal-bottom-nav {
        display: none !important;
    }
}

.site-main {
    flex: 1;
    padding-block: var(--space-8);
}

.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: 0.875rem;
}
.alert--success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-border);
}

.alert--error {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border: 1px solid var(--color-danger-border);
}

.flash-message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.flash-message--success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border-right: 4px solid var(--color-success-border);
}

.flash-message--error {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border-right: 4px solid var(--color-danger-border);
}

.flash-message--warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-right: 4px solid var(--color-warning-border);
}

.outcome-label--approve {
    color: var(--color-success-text);
    font-weight: 700;
}

.outcome-label--reject {
    color: var(--color-danger-text);
    font-weight: 700;
}

.btn--danger-outline {
    color: var(--color-danger-text) !important;
    border-color: var(--color-danger-border) !important;
}

.btn--danger-outline:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger-text) !important;
}

.hero {
    background: linear-gradient(135deg, #062a3f 0%, var(--color-primary) 45%, #134e6f 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 4vw, 2.75rem);
    margin-bottom: var(--space-8);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}
.hero__badge {
    display: inline-block;
    font-size: 0.75rem;
    background: rgba(255,255,255,0.15);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    margin-bottom: var(--space-3);
}
.hero__title {
    margin: 0 0 var(--space-3);
    font-size: clamp(1.35rem, 3vw, 2rem);
    font-weight: 700;
    max-width: 28ch;
}
.hero__lead {
    margin: 0;
    max-width: 52ch;
    font-size: clamp(0.875rem, 0.85rem + 0.15vw, 0.95rem);
    line-height: 1.7;
    color: rgba(248, 250, 252, 0.92);
}
.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
.section-head h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.layout-split {
    display: grid;
    gap: var(--space-8);
}
@media (min-width: 960px) {
    .layout-split { grid-template-columns: 1fr 320px; }
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    color: var(--color-text);
}

@media (hover: hover) {
    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 20px 48px rgba(11, 61, 92, 0.14);
    }
}

.service-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    margin-bottom: var(--space-8);
}

.service-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    min-height: 140px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
a.service-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 20px 48px rgba(11, 61, 92, 0.14);
    transform: translateY(-3px);
    color: inherit;
}
.service-card:not(a):hover {
    transform: none;
    border-color: var(--color-border);
    box-shadow: var(--shadow-sm);
}
.service-card__icon {
    width: 40px;
    height: 40px;
    color: var(--color-primary);
}
.service-card__title {
    font-weight: 700;
    font-size: 1rem;
    margin: 0;
}
.service-card__desc {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--color-muted);
    flex: 1;
}

.update-list { list-style: none; margin: 0; padding: 0; }
.update-item {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-border-subtle);
}
.update-item:last-child { border-bottom: none; }
.update-item__meta {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-bottom: var(--space-2);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.tag {
    display: inline-block;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
}
.update-item__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}
.update-item__title a { text-decoration: none; color: var(--color-text); }
.update-item__title a:hover { color: var(--color-primary); }

.site-footer {
    margin-top: auto;
    padding: var(--space-6) 0;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: 0.8125rem;
    color: var(--color-muted);
    text-align: center;
}

html:not([data-theme="dark"]) .site-footer {
    background: var(--color-surface);
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: var(--color-bg);
}
.auth-card {
    width: min(100%, 400px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    box-shadow: var(--shadow-sm);
    text-align: center;
}
.auth-card__logo { max-width: 160px; margin: 0 auto var(--space-4); display: block; }
.auth-card h1 {
    margin: 0 0 var(--space-2);
    font-size: 1.15rem;
    font-weight: 700;
}
.auth-card p.sub {
    margin: 0 0 var(--space-6);
    font-size: 0.8125rem;
    color: var(--color-muted);
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    text-align: start;
}
.auth-form label {
    font-size: 0.8125rem;
    font-weight: 600;
}
.auth-form input {
    width: 100%;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background: var(--color-surface);
    color: var(--color-text);
}

.auth-form input::placeholder {
    color: var(--color-muted);
    opacity: 1;
}
.auth-form input:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}
.auth-form .btn { width: 100%; }
.auth-form .recaptcha-wrap { margin-top: 0.15rem; }
.auth-back {
    display: inline-block;
    margin-top: var(--space-4);
    font-size: 0.8125rem;
}
.dev-otp {
    background: var(--color-warning-bg);
    border: 1px dashed var(--color-warning-border);
    color: var(--color-warning-text);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: var(--space-4);
}
.error-box {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    margin-bottom: var(--space-4);
    text-align: start;
    border: 1px solid var(--color-danger-border);
}

.prose-update {
    line-height: 1.85;
    white-space: pre-wrap;
}

.pagination { margin-top: var(--space-6); }
.pagination nav { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--color-text);
}
.pagination a:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pagination span[aria-current="page"] {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
}

/* صفحه‌بندی فارسی — یک ردیف، دکمه‌های یکپارچه */
.pagination-panel {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border, #e2e8f0);
    direction: rtl;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.pagination-panel__meta {
    margin: 0;
    flex: 0 1 auto;
    white-space: nowrap;
    color: var(--color-muted, #64748b);
    font-size: 0.8125rem;
    line-height: 1.4;
}
.pagination-panel__dot {
    margin: 0 0.15rem;
    color: #cbd5e1;
}
.pagination-panel__links {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 10px;
    background: var(--color-surface, #fff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    overflow: hidden;
    flex: 0 0 auto;
}
.pagination-panel__links > li {
    display: flex;
}
.pagination-panel__links > li + li {
    border-right: 1px solid var(--color-border, #e2e8f0);
}
.pagination-panel__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.35rem;
    min-height: 2.35rem;
    padding: 0 0.7rem;
    border: 0;
    background: transparent;
    color: var(--color-text, #0f172a);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.pagination-panel__btn.is-nav {
    padding: 0 0.85rem;
    color: var(--color-muted, #475569);
}
a.pagination-panel__btn:hover {
    background: #f1f5f9;
    color: var(--color-primary, #0f766e);
}
.pagination-panel__btn.is-current {
    background: var(--color-primary, #0f766e);
    color: var(--color-on-primary, #fff);
}
.pagination-panel__btn.is-disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}
.pagination-panel__btn.is-ellipsis {
    min-width: 2rem;
    opacity: 0.55;
    font-weight: 500;
    cursor: default;
}

@media (max-width: 720px) {
    .pagination-panel {
        gap: 0.75rem;
    }
    .pagination-panel__meta {
        font-size: 0.75rem;
    }
}

.service-grid--single {
    grid-template-columns: minmax(0, 22rem);
}

.portal-contact-list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.875rem;
}

.portal-contact-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 1rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--color-border);
}

.portal-contact-list li:last-child {
    border-bottom: none;
}

.portal-contact-list span {
    color: var(--color-muted);
}

.portal-contact-list a {
    font-weight: 600;
}

.portal-contact-list strong {
    font-weight: 600;
    color: var(--color-text);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.theme-toggle:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.theme-toggle__icon {
    display: inline-flex;
    line-height: 0;
}

.theme-toggle__icon--moon {
    display: none;
}

[data-theme="dark"] .theme-toggle__icon--sun {
    display: none;
}

[data-theme="dark"] .theme-toggle__icon--moon {
    display: inline-flex;
}

.theme-toggle--compact .theme-toggle__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.theme-toggle--compact {
    padding: 0.5rem;
    min-width: 44px;
    justify-content: center;
}

.site-footer__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.panel-sidebar__theme {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-border);
}

.panel-sidebar__theme .theme-toggle {
    width: 100%;
    justify-content: center;
}

@media (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {
    .update-item__meta,
    .service-card__desc,
    .portal-contact-list span,
    .emp-track__copy {
        font-weight: 500;
    }
}
