/*
 * Shared components of the standalone portal pages (home, appointment, report).
 * Colors come from portal-theme.css tokens, so every rule works in day and night mode.
 * Page width: set --page-width on .page. Page accent: data-accent on <html>.
 */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    font-family: Vazir, Tahoma, sans-serif;
    color: var(--text);
    background-color: var(--bg);
    transition: background-color 0.4s ease, color 0.4s ease;
}

button, input, select, textarea {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Animated background: slow photo zoom + scanner sweep ---------- */
.backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-photo {
    position: absolute;
    inset: 0;
    background: url('/img/bg/bg.jpg') center / cover no-repeat;
    transform-origin: 60% 40%;
    animation: kenburns 40s ease-in-out infinite alternate;
}

.bg-shade {
    position: absolute;
    inset: 0;
    background: var(--shade);
    transition: background 0.4s ease;
}

.bg-scan {
    position: absolute;
    right: 0;
    left: 0;
    top: -30%;
    height: 30%;
    background: linear-gradient(180deg, transparent 0%, rgba(var(--accent-rgb), 0.05) 45%, rgba(var(--accent-rgb), 0.16) 50%, rgba(var(--accent-rgb), 0.05) 55%, transparent 100%);
    animation: scan 11s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

    .bg-scan::after {
        content: "";
        position: absolute;
        right: 0;
        left: 0;
        top: 50%;
        height: 1px;
        background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.55), transparent);
        box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.55);
    }

@keyframes kenburns {
    from { transform: scale(1) translate(0, 0); }
    to { transform: scale(1.14) translate(-2%, 1.5%); }
}

@keyframes scan {
    0% { top: -30%; }
    70%, 100% { top: 110%; }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Page frame ---------- */
.page {
    position: relative;
    z-index: 1;
    flex: 1;
    width: 100%;
    max-width: var(--page-width, 500px);
    margin: 0 auto;
    padding: 40px 16px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 26px;
}

.hero {
    text-align: center;
    animation: rise 0.8s var(--ease) both;
}

.hero-logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 18px 32px;
    border-radius: 24px;
    background: var(--logo-plate);
    border: 1px solid var(--surface-border);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 70px var(--hero-glow);
}

.hero-logo {
    display: block;
    max-height: 110px;
    max-width: min(300px, 100%);
    object-fit: contain;
    filter: var(--logo-shadow);
}

/* ---------- Card ---------- */
.card {
    position: relative;
    overflow: hidden;
    padding: 30px 26px 26px;
    border-radius: 24px;
    border: 1px solid var(--surface-border);
    background: linear-gradient(180deg, var(--surface-top) 0%, var(--surface-bottom) 100%);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card), inset 0 1px 0 var(--surface-shine);
    animation: rise 0.8s 0.15s var(--ease) both;
}

    .card::before {
        content: "";
        position: absolute;
        top: 0;
        right: 18%;
        left: 18%;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--accent);
        box-shadow: 0 0 18px var(--accent);
    }

.card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.card-icon {
    position: relative;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
}

    .card-icon::before {
        content: "";
        position: absolute;
        inset: 4px;
        border-radius: 50%;
        background: var(--accent);
        filter: blur(18px);
        opacity: 0.35;
    }

    .card-icon img {
        position: relative;
        width: 56px;
        height: 56px;
        object-fit: contain;
    }

.card-kicker {
    display: block;
    margin-bottom: 2px;
    font-size: 13px;
    color: var(--text-muted);
}

.card-title {
    margin: 0 0 4px;
    font-size: 21px;
    font-weight: bold;
    line-height: 1.6;
}

.card-desc {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.8;
    color: var(--text-muted);
}

.step-badge {
    display: inline-block;
    margin-bottom: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    color: var(--accent-ink);
    background: rgba(var(--accent-rgb), 0.12);
    border: 1px solid rgba(var(--accent-rgb), 0.30);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: bold;
}

    .section-title::before {
        content: "";
        width: 4px;
        height: 16px;
        border-radius: 4px;
        background: var(--accent);
        box-shadow: 0 0 10px var(--accent);
    }

/* ---------- Form fields ---------- */
.field {
    margin-bottom: 16px;
    min-width: 0;
}

    .field > label,
    .field-label {
        display: block;
        margin-bottom: 7px;
        font-size: 14px;
        color: var(--text-muted);
    }

.hint {
    margin: 6px 0 0;
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--text-faint);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--field-border);
    background: var(--field-bg);
    color: var(--text);
    font-size: 16px;
    transition: border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.textarea {
    min-height: 84px;
    resize: vertical;
    line-height: 1.8;
}

.input.numeric {
    direction: ltr;
    text-align: center;
    letter-spacing: 1px;
    font-size: 17px;
}

.input::placeholder,
.textarea::placeholder {
    direction: rtl;
    letter-spacing: 0;
    font-size: 14px;
    color: var(--text-faint);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--field-bg-focus);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.18);
}

[aria-invalid="true"] {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 4px var(--danger-bg) !important;
}

.select {
    appearance: none;
    padding-left: 34px;
    cursor: pointer;
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px;
}

    .select:disabled {
        cursor: not-allowed;
        opacity: 0.55;
    }

    .select option {
        background: var(--option-bg);
        color: var(--option-text);
    }

input[type="time"].input::-webkit-calendar-picker-indicator {
    filter: var(--picker-icon-filter);
    opacity: 0.7;
}

/* Two or more options rendered as one pill-shaped radio group */
.segmented {
    display: flex;
    gap: 4px;
    margin: 0;
    padding: 4px;
    border: 1px solid var(--field-border);
    border-radius: 14px;
    background: var(--chip);
}

    .segmented legend {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .segmented label {
        flex: 1;
        position: relative;
    }

    .segmented input {
        position: absolute;
        inset: 0;
        margin: 0;
        opacity: 0;
        cursor: pointer;
    }

    .segmented span {
        display: block;
        padding: 9px 12px;
        border-radius: 10px;
        text-align: center;
        font-size: 15px;
        color: var(--text-muted);
        transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    }

    .segmented input:checked + span {
        background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
        color: var(--on-accent);
        font-weight: bold;
        box-shadow: 0 6px 16px -6px rgba(var(--accent-rgb), 0.8);
    }

    .segmented input:focus-visible + span {
        outline: 3px solid var(--accent);
        outline-offset: 2px;
    }

/* ---------- Messages ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger-ink);
    font-size: 14.5px;
    line-height: 1.8;
    animation: fade 0.35s var(--ease) both;
}

    .alert:empty {
        display: none;
    }

    .alert svg {
        flex-shrink: 0;
        width: 20px;
        height: 20px;
        margin-top: 3px;
    }

    .alert ul {
        margin: 0;
        padding: 0 18px 0 0;
    }

.alert-warning {
    border-color: var(--warning-border);
    background: var(--warning-bg);
    color: var(--warning-ink);
}

.alert-success {
    border-color: var(--success-border);
    background: var(--success-bg);
    color: var(--success-ink);
}

.alert-info {
    border-color: var(--line);
    background: var(--chip);
    color: var(--text-muted);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 18px;
    border: 0;
    border-radius: 14px;
    font-size: 16px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), opacity 0.3s ease, background-color 0.3s ease;
}

    .btn:hover {
        transform: translateY(-2px);
    }

    .btn:focus-visible {
        outline: 3px solid var(--accent);
        outline-offset: 3px;
    }

    .btn:disabled {
        cursor: progress;
        opacity: 0.75;
        transform: none;
    }

    .btn svg {
        width: 18px;
        height: 18px;
    }

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: var(--on-accent);
    box-shadow: 0 10px 26px -8px rgba(var(--accent-rgb), 0.75);
}

    .btn-primary:hover {
        box-shadow: 0 14px 30px -8px rgba(var(--accent-rgb), 0.9);
    }

.btn-block {
    width: 100%;
}

.btn-ghost {
    border: 1px solid var(--field-border);
    background: var(--chip);
    color: var(--text);
    font-weight: normal;
}

    .btn-ghost:hover {
        background: var(--chip-hover);
    }

.btn-pay {
    background: var(--warning);
    color: var(--on-warning);
}

.spinner {
    display: inline-block;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(var(--accent-rgb), 0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn .spinner {
    display: none;
    width: 18px;
    height: 18px;
    border-color: color-mix(in srgb, var(--on-accent) 30%, transparent);
    border-top-color: var(--on-accent);
}

.btn.is-loading .spinner {
    display: inline-block;
}

.btn.is-loading svg {
    display: none;
}

/* ---------- Report download row ---------- */
.result-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border-radius: 14px;
    border: 1px solid rgba(var(--accent-rgb), 0.35);
    background: rgba(var(--accent-rgb), 0.10);
    color: var(--text);
    text-decoration: none;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s var(--ease);
}

    .result-link:hover {
        background: rgba(var(--accent-rgb), 0.20);
        border-color: var(--accent);
        transform: translateX(-3px);
    }

    .result-link:focus-visible {
        outline: 3px solid var(--accent);
        outline-offset: 3px;
    }

    .result-link .ico {
        flex-shrink: 0;
        display: grid;
        place-items: center;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        background: rgba(var(--accent-rgb), 0.18);
        color: var(--accent-ink);
    }

        .result-link .ico svg {
            width: 20px;
            height: 20px;
        }

    .result-link .label {
        flex: 1;
        font-size: 15px;
        line-height: 1.6;
    }

    .result-link .go {
        padding: 5px 12px;
        border-radius: 999px;
        background: var(--accent);
        color: var(--on-accent);
        font-size: 13px;
        font-weight: bold;
        white-space: nowrap;
    }

/* ---------- Success screen ---------- */
.result {
    text-align: center;
}

.result-icon {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin: 4px auto 16px;
    border-radius: 50%;
    color: var(--success);
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    box-shadow: 0 0 40px -6px var(--success-border);
}

    .result-icon svg {
        width: 38px;
        height: 38px;
    }

/* ---------- Back link & footer ---------- */
.back {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 14px;
    text-decoration: none;
    transition: color 0.3s ease, background-color 0.3s ease;
    animation: rise 0.8s 0.3s var(--ease) both;
}

    .back:hover,
    .back:focus-visible {
        color: var(--text);
        background: var(--chip-hover);
    }

    .back svg {
        width: 16px;
        height: 16px;
    }

.footer {
    position: relative;
    z-index: 1;
    padding: 12px 16px;
    text-align: center;
    font-size: 12.5px;
    color: var(--footer-text);
}

    .footer a {
        color: var(--footer-link);
        text-decoration: none;
    }

/* ---------- Phones ---------- */
@media (max-width: 576px) {
    .page {
        padding: 64px 16px 16px;
        gap: 22px;
    }

    .hero-logo-wrap {
        padding: 14px 22px;
        border-radius: 20px;
    }

    .hero-logo {
        max-height: 80px;
    }

    .card {
        padding: 24px 18px 20px;
        border-radius: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
