/*
 * Poshesh first-run installer — a modern, self-contained RTL wizard.
 * Reuses the platform's Bootstrap RTL, Remix icons, and Vazirmatn font.
 * All visual styling for the wizard (inputs, buttons, stepper, cards) is defined here
 * and scoped to .pshi-card, so it never relies on subtle Velzon/Bootstrap defaults.
 */
:root {
    --pshi-accent: #6366f1;
    --pshi-accent-strong: #4f46e5;
    --pshi-accent-dark: #4338ca;
    --pshi-accent-soft: #eef2ff;
    --pshi-ink: #1e293b;
    --pshi-muted: #64748b;
    --pshi-line: #e2e8f0;
    --pshi-line-strong: #cbd5e1;
    --pshi-field-bg: #f8fafc;
    --pshi-ok: #16a34a;
    --pshi-ok-soft: #dcfce7;
    --pshi-bad: #dc2626;
    --pshi-bad-soft: #fee2e2;
    --pshi-radius: 1.5rem;
}

.pshi-body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(99, 102, 241, .18), transparent 60%),
        radial-gradient(900px 500px at 0% 110%, rgba(79, 70, 229, .16), transparent 55%),
        linear-gradient(135deg, #eef2ff 0%, #f8fafc 50%, #eef2ff 100%);
    color: var(--pshi-ink);
    -webkit-font-smoothing: antialiased;
}

.pshi-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
}

.pshi-card {
    width: 100%;
    max-width: 820px;
    background: #fff;
    border-radius: var(--pshi-radius);
    box-shadow:
        0 40px 80px -32px rgba(49, 46, 129, .45),
        0 8px 24px -12px rgba(15, 23, 42, .12),
        0 0 0 1px rgba(255, 255, 255, .6) inset;
    overflow: hidden;
}

/* ---- Header + stepper ---- */
.pshi-head {
    position: relative;
    background: linear-gradient(135deg, var(--pshi-accent-dark) 0%, var(--pshi-accent-strong) 55%, #7c3aed 100%);
    color: #fff;
    padding: 1.9rem 2.1rem 1.6rem;
    overflow: hidden;
}

.pshi-head::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(420px 220px at 12% -30%, rgba(255, 255, 255, .22), transparent 70%),
        radial-gradient(360px 200px at 100% 130%, rgba(255, 255, 255, .12), transparent 70%);
    pointer-events: none;
}

.pshi-brand {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: .65rem;
    margin-bottom: 1.6rem;
}

.pshi-brand-mark {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: .3px;
}

.pshi-brand-sub {
    font-size: .95rem;
    opacity: .82;
    font-weight: 500;
}

.pshi-brand-sub::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    vertical-align: middle;
    margin-inline-end: .55rem;
    opacity: .7;
}

.pshi-steps {
    position: relative;
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: .25rem;
}

.pshi-steps li {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    position: relative;
    opacity: .62;
    transition: opacity .3s ease, transform .3s ease;
    font-size: .8rem;
    font-weight: 500;
}

/* Connecting track sits behind the number, joining to the previous step */
.pshi-steps li::before {
    content: "";
    position: absolute;
    top: 17px;
    right: 50%;
    width: 100%;
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .22);
    z-index: 0;
    transition: background .3s ease;
}

.pshi-steps li:first-child::before { display: none; }
.pshi-steps li.is-active::before,
.pshi-steps li.is-done::before { background: rgba(255, 255, 255, .85); }

.pshi-num {
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .16);
    border: 2px solid rgba(255, 255, 255, .45);
    font-weight: 700;
    font-size: .95rem;
    transition: all .3s ease;
}

.pshi-steps li.is-active { opacity: 1; }
.pshi-steps li.is-active .pshi-num {
    background: #fff;
    color: var(--pshi-accent-dark);
    border-color: #fff;
    transform: scale(1.12);
    box-shadow: 0 8px 20px -6px rgba(0, 0, 0, .4);
}
.pshi-steps li.is-done { opacity: 1; }
.pshi-steps li.is-done .pshi-num {
    background: rgba(255, 255, 255, .95);
    color: var(--pshi-accent-dark);
    border-color: rgba(255, 255, 255, .95);
}
.pshi-cap { white-space: nowrap; }

/* ---- Body panels ---- */
.pshi-panel { padding: 2rem 2.1rem; }
.pshi-panel[hidden] { display: none; }

.pshi-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0 0 .55rem;
    letter-spacing: -.2px;
}
.pshi-lead {
    color: var(--pshi-muted);
    margin-bottom: 1.5rem;
    line-height: 1.85;
    font-size: .95rem;
}

.pshi-checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.pshi-checklist li {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .95rem 1.1rem;
    background: var(--pshi-field-bg);
    border: 1px solid var(--pshi-line);
    border-radius: .9rem;
    font-size: .92rem;
    transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.pshi-checklist li:hover {
    border-color: var(--pshi-line-strong);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px -10px rgba(49, 46, 129, .3);
}
.pshi-checklist i {
    color: var(--pshi-accent);
    font-size: 1.15rem;
    width: 2.2rem;
    height: 2.2rem;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pshi-accent-soft);
    border-radius: .65rem;
}

/* ---- Form fields ---- */
.pshi-card .form-label {
    font-weight: 600;
    font-size: .875rem;
    color: var(--pshi-ink);
    margin-bottom: .45rem;
}

.pshi-card .form-control,
.pshi-card .form-select {
    background-color: var(--pshi-field-bg);
    border: 1.5px solid var(--pshi-line);
    border-radius: .7rem;
    padding: .65rem .9rem;
    font-size: .95rem;
    color: var(--pshi-ink);
    box-shadow: none;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.pshi-card .form-control::placeholder { color: #94a3b8; opacity: 1; }

.pshi-card .form-control:hover,
.pshi-card .form-select:hover {
    border-color: var(--pshi-line-strong);
}

.pshi-card .form-control:focus,
.pshi-card .form-select:focus {
    background-color: #fff;
    border-color: var(--pshi-accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .16);
    outline: none;
}

.pshi-card .form-control.is-invalid,
.pshi-card .form-select.is-invalid {
    border-color: var(--pshi-bad);
    background-color: #fff;
}
.pshi-card .form-control.is-invalid:focus {
    box-shadow: 0 0 0 4px rgba(220, 38, 38, .14);
}

.pshi-block {
    background: linear-gradient(180deg, #fff, var(--pshi-field-bg));
    border: 1px solid var(--pshi-line);
    border-radius: 1rem;
    padding: 1.25rem 1.35rem;
    margin-bottom: 1.1rem;
}
.pshi-block-title {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.pshi-block-title i {
    color: var(--pshi-accent);
    font-size: 1.15rem;
}

.pshi-divider { border: 0; border-top: 1px dashed var(--pshi-line-strong); margin: .5rem 0; }
.pshi-hint { color: var(--pshi-muted); font-size: .82rem; margin: .4rem 0 0; line-height: 1.7; }

.pshi-field-error { display: block; color: var(--pshi-bad); font-size: .82rem; margin-top: .35rem; min-height: 1px; font-weight: 500; }

/* ---- Segmented control (auth mode / cache) ---- */
.pshi-card .btn-group[role="group"] {
    background: var(--pshi-field-bg);
    border: 1.5px solid var(--pshi-line);
    border-radius: .8rem;
    padding: .3rem;
    gap: .3rem;
    display: inline-flex;
    width: 100%;
    max-width: 420px;
}
.pshi-card .btn-group .btn-check + .btn.btn-outline-primary {
    flex: 1 1 0;
    border: 0;
    border-radius: .55rem !important;
    background: transparent;
    color: var(--pshi-muted);
    font-weight: 600;
    font-size: .9rem;
    padding: .5rem .75rem;
    box-shadow: none;
    transition: all .18s ease;
}
.pshi-card .btn-group .btn-check + .btn.btn-outline-primary:hover {
    color: var(--pshi-accent-dark);
    background: rgba(99, 102, 241, .08);
}
.pshi-card .btn-group .btn-check:checked + .btn.btn-outline-primary {
    background: #fff;
    color: var(--pshi-accent-dark);
    box-shadow: 0 2px 8px -2px rgba(49, 46, 129, .25);
}
.pshi-card .btn-group .btn-check:focus-visible + .btn.btn-outline-primary {
    outline: 2px solid rgba(99, 102, 241, .5);
    outline-offset: 1px;
}

/* ---- Switches ---- */
.pshi-card .form-check.form-switch {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .7rem .9rem;
    background: var(--pshi-field-bg);
    border: 1px solid var(--pshi-line);
    border-radius: .7rem;
    min-height: auto;
    margin: 0;
}
.pshi-card .form-switch .form-check-input {
    width: 2.4em;
    height: 1.3em;
    margin: 0;
    flex: 0 0 auto;
    background-color: #cbd5e1;
    border-color: #cbd5e1;
    cursor: pointer;
    box-shadow: none;
    transition: background-color .18s ease, border-color .18s ease;
}
.pshi-card .form-switch .form-check-input:checked {
    background-color: var(--pshi-accent);
    border-color: var(--pshi-accent);
}
.pshi-card .form-switch .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
    border-color: var(--pshi-accent);
}
.pshi-card .form-switch .form-check-label {
    font-weight: 600;
    font-size: .88rem;
    color: var(--pshi-ink);
    cursor: pointer;
    margin: 0;
}

/* Conditional field groups, revealed by JS */
.pshi-sql-only, .pshi-redis-only, .pshi-mongo-only, .pshi-key-only { display: none; }
.pshi-card.pshi-sql .pshi-sql-only { display: block; }
.pshi-card.pshi-redis .pshi-redis-only { display: flex; }
.pshi-card.pshi-mongo .pshi-mongo-only { display: flex; }
.pshi-card.pshi-license-key .pshi-key-only { display: block; }

/* ---- Licence step ---- */
.pshi-license-modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.pshi-license-card {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: 1.15rem 1.25rem;
    border: 1.5px solid var(--pshi-line);
    border-radius: 1rem;
    background: var(--pshi-field-bg);
    cursor: pointer;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.pshi-license-card:hover { border-color: var(--pshi-accent); }

/* The radio stays a real input (keyboard and screen readers get the native control); the card around
   it carries the selected state. */
.pshi-license-card input[type="radio"] {
    margin: .2rem 0 0;
    flex: 0 0 auto;
    accent-color: var(--pshi-accent);
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
}
.pshi-license-card:has(input:checked) {
    border-color: var(--pshi-accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .16);
}
.pshi-license-card:has(input:disabled) {
    opacity: .6;
    cursor: not-allowed;
}
.pshi-license-card:has(input:disabled):hover { border-color: var(--pshi-line); }
.pshi-license-body { display: flex; flex-direction: column; gap: .35rem; }
.pshi-license-title {
    font-weight: 700;
    font-size: .98rem;
    color: var(--pshi-ink);
    display: flex;
    align-items: center;
    gap: .4rem;
}
.pshi-license-title i { color: var(--pshi-accent); }
.pshi-license-note {
    font-size: .84rem;
    line-height: 1.7;
    color: var(--pshi-muted);
}
.pshi-license-input {
    font-family: Consolas, "Courier New", monospace;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* ---- Buttons ---- */
.pshi-card .btn {
    font-weight: 600;
    border-radius: .7rem;
    padding: .62rem 1.4rem;
    font-size: .95rem;
    transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease;
}
.pshi-card .btn:active { transform: translateY(1px); }

.pshi-card .btn-primary {
    background: linear-gradient(135deg, var(--pshi-accent-strong), var(--pshi-accent-dark));
    border: 0;
    box-shadow: 0 10px 22px -10px rgba(79, 70, 229, .7);
}
.pshi-card .btn-primary:hover {
    box-shadow: 0 14px 28px -10px rgba(79, 70, 229, .8);
    filter: brightness(1.05);
}

.pshi-card .btn-success {
    background: linear-gradient(135deg, #16a34a, #15803d);
    border: 0;
    box-shadow: 0 10px 22px -10px rgba(22, 163, 74, .7);
}
.pshi-card .btn-success:hover { filter: brightness(1.05); }

.pshi-card .btn-light {
    background: #fff;
    border: 1.5px solid var(--pshi-line);
    color: var(--pshi-ink);
}
.pshi-card .btn-light:hover {
    background: var(--pshi-field-bg);
    border-color: var(--pshi-line-strong);
}

.pshi-card .btn-outline-secondary {
    border: 1.5px solid var(--pshi-line-strong);
    color: var(--pshi-ink);
    background: #fff;
}
.pshi-card .btn-outline-secondary:hover {
    background: var(--pshi-accent-soft);
    border-color: var(--pshi-accent);
    color: var(--pshi-accent-dark);
}

/* ---- Test connection ---- */
.pshi-test-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--pshi-line);
    flex-wrap: wrap;
}
.pshi-test-result { font-size: .9rem; font-weight: 600; }
.pshi-test-result.is-ok { color: var(--pshi-ok); }
.pshi-test-result.is-bad { color: var(--pshi-bad); }

/* ---- Review ---- */
.pshi-review {
    margin: 0;
    border: 1px solid var(--pshi-line);
    border-radius: 1rem;
    overflow: hidden;
    background: var(--pshi-field-bg);
}
.pshi-review div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .8rem 1.1rem;
    border-bottom: 1px solid var(--pshi-line);
}
.pshi-review div:last-child { border-bottom: 0; }
.pshi-review dt { color: var(--pshi-muted); margin: 0; font-weight: 500; font-size: .9rem; }
.pshi-review dd { margin: 0; font-weight: 700; direction: ltr; text-align: left; unicode-bidi: plaintext; }

.pshi-summary {
    margin: 1.5rem 2.1rem 0;
    border-radius: .8rem;
    border: 0;
    font-weight: 500;
}
.pshi-summary.alert-danger { background: var(--pshi-bad-soft); color: #991b1b; }
.pshi-summary.alert-success { background: var(--pshi-ok-soft); color: #166534; }

/* ---- Footer ---- */
.pshi-foot {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.25rem 2.1rem 1.75rem;
    border-top: 1px solid var(--pshi-line);
    background: linear-gradient(180deg, #fff, var(--pshi-field-bg));
}
.pshi-foot-spacer { flex: 1 1 auto; }

.pshi-footnote { color: var(--pshi-muted); font-size: .82rem; margin-top: 1.5rem; opacity: .85; }

/* ---- Completion ---- */
.pshi-complete-badge {
    width: 84px;
    height: 84px;
    margin: .5rem auto 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pshi-ok-soft);
    color: var(--pshi-ok);
    font-size: 2.6rem;
    box-shadow: 0 0 0 10px rgba(22, 163, 74, .08);
}
.pshi-manual a { font-weight: 600; color: var(--pshi-accent-dark); }

@media (max-width: 575.98px) {
    .pshi-cap { display: none; }
    .pshi-panel { padding: 1.4rem 1.25rem; }
    .pshi-head { padding: 1.5rem 1.35rem 1.35rem; }
    .pshi-foot { padding: 1.1rem 1.25rem 1.4rem; }
    .pshi-summary { margin-inline: 1.25rem; }
    .pshi-card .btn { padding: .6rem 1rem; }
    .pshi-title { font-size: 1.25rem; }
}
