/* ============================================================
   GSM One — Installation Wizard Stylesheet
   Same visual identity as the sign-in forms (light two-panel card,
   Barlow, blue accent, 12px fields). Self-contained: it must work
   before any database exists, so it depends on no other stylesheet.
   ============================================================ */

/* ---------- Font Loading (self-contained) ---------- */
@font-face {
    font-family: 'Barlow';
    src: url('/assets/fonts/barlow/Barlow-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Barlow';
    src: url('/assets/fonts/barlow/Barlow-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Barlow';
    src: url('/assets/fonts/barlow/Barlow-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Barlow';
    src: url('/assets/fonts/barlow/Barlow-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Barlow';
    src: url('/assets/fonts/barlow/Barlow-ExtraBold.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

/* ---------- CSS Variables ----------
   --color-* names are kept: the step views reference them inline. */
:root {
    color-scheme: light;
    --a-acc: #1e88e5;
    --a-acc-d: #1565c0;
    --a-acc2: #12b3a6;
    --a-ink: #15243d;
    --a-muted: #64748b;
    --a-line: #e4e9f2;
    --a-field: #f6f8fc;
    --a-radius: 20px;

    --color-primary: #1e88e5;
    --color-primary-light: #42a5f5;
    --color-primary-dark: #1565c0;
    --color-success: #16a34a;
    --color-success-bg: #e8f6ec;
    --color-danger: #e5484d;
    --color-danger-bg: #fdecee;
    --color-warning: #f59e0b;
    --color-warning-bg: #fff7e6;
    --color-info: #1e88e5;
    --color-info-bg: #eef5ff;
    --color-gray-50: #f6f8fc;
    --color-gray-100: #eef2f8;
    --color-gray-200: #e4e9f2;
    --color-gray-300: #cfd8e6;
    --color-gray-400: #8a98ad;
    --color-gray-500: #64748b;
    --color-gray-600: #4a5a73;
    --color-gray-700: #33445f;
    --color-gray-800: #1f2f48;
    --color-gray-900: #15243d;
    --radius: 12px;
    --radius-lg: 20px;
    --shadow-lg: 0 40px 110px -40px rgba(20, 40, 80, .4);
    --transition: 150ms cubic-bezier(.4, 0, .2, 1);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.install-body {
    font-family: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background:
        radial-gradient(1000px 560px at 82% -10%, rgba(30, 136, 229, .10), transparent 60%),
        radial-gradient(820px 480px at 6% 112%, rgba(18, 179, 166, .10), transparent 55%),
        #eef3fb;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    color: var(--a-ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Wrapper ---------- */
.install-wrapper {
    width: 100%;
    max-width: 1040px;
    min-width: 0;
    margin: 0 auto;
}

/* ---------- Main Box ---------- */
.installer-box {
    position: relative;
    display: grid;
    grid-template-columns: .8fr 1.4fr;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--a-line);
    border-radius: var(--a-radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    overflow: clip;
    animation: iRise .5s cubic-bezier(.2, .8, .25, 1) both;
}

@keyframes iRise {
    from { opacity: 0; transform: translateY(16px) scale(.99); }
    to { opacity: 1; transform: none; }
}

/* ============================================================
   LEFT: ARTWORK
   ============================================================ */
.installer-art {
    position: relative;
    /* `clip` (not `hidden`) so the sticky artwork below can still stick */
    overflow: hidden;
    overflow: clip;
    /* First screen: artwork vertically centred in the viewport */
    padding: max(36px, calc((100vh - 560px) / 2 - 28px)) 32px 36px;
    background: linear-gradient(160deg, #eaf4ff, #e0edff);
    border-right: 1px solid var(--a-line);
}

/* On long steps the artwork stays in view while the form scrolls */
.art-stack {
    position: sticky;
    top: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.installer-art::before {
    content: "";
    position: absolute;
    width: 380px;
    height: 380px;
    border-radius: 50%;
    top: -110px;
    right: -130px;
    background: radial-gradient(circle, rgba(30, 136, 229, .22), transparent 62%);
    pointer-events: none;
}

.installer-art img {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 18px 34px rgba(30, 80, 160, .16));
}

/* Slim artwork banner above the form, only where the left column is hidden */
.art-mobile { display: none; }

/* ============================================================
   RIGHT: CONTENT
   ============================================================ */
.installer-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
}


/* ---------- Step badge + progress bars (same pattern as account creation) ---------- */
.wiz-head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.wiz-badge {
    flex-shrink: 0;
    margin-top: 6px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--a-acc);
    background: #eaf4ff;
    border: 1px solid #d4e6fb;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.wiz-dots {
    display: flex;
    gap: 6px;
    margin: 16px 38px 0;
}

.wiz-dots i,
.wiz-dots a {
    position: relative;
    display: block;
    width: 34px;
    height: 4px;
    border-radius: 3px;
    background: var(--a-line);
    transition: .2s;
}

.wiz-dots .on { background: var(--a-acc); }

/* Finished steps are links: a larger invisible hit area for fingers */
.wiz-dots a::after {
    content: '';
    position: absolute;
    inset: -10px -3px;
}

.wiz-dots a:hover { background: var(--a-acc-d); }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.installer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.content-header {
    padding: 22px 38px 0;
    animation: wizIn .32s cubic-bezier(.2, .8, .25, 1) both;
}

.content-header h3 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--a-ink);
    margin-bottom: 4px;
}

.content-header .excerpt {
    font-size: .88rem;
    color: var(--a-muted);
    margin: 0;
    max-width: 62ch;
}

.content-body {
    flex: 1;
    padding: 20px 38px;
    animation: wizIn .32s cubic-bezier(.2, .8, .25, 1) both;
}

@keyframes wizIn {
    from { opacity: 0; transform: translateX(22px); }
    to { opacity: 1; transform: none; }
}

.content-footer {
    padding: 16px 38px 22px;
    border-top: 1px solid var(--a-line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #fbfcfe;
}


/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 11px;
    margin-bottom: 14px;
    font-size: .86rem;
    line-height: 1.45;
}

.alert-icon {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1.2;
}

.alert-success { background: #e8f6ec; color: #1a6b34; border: 1px solid #c7e9d1; }
.alert-danger { background: #fdecee; color: #b3261e; border: 1px solid #f7ccd0; }
.alert-warning { background: var(--color-warning-bg); color: #8a5a00; border: 1px solid #fde2a6; }
.alert-info { background: var(--color-info-bg); color: #1e4f8f; border: 1px solid #cfe2fb; }

.alert-action {
    justify-content: space-between;
    align-items: center;
}

.alert-text { flex: 1; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    padding: 0 22px;
    font-size: .95rem;
    font-weight: 800;
    font-family: inherit;
    border-radius: 12px;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1.2;
    white-space: nowrap;
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
    background: linear-gradient(135deg, var(--a-acc), var(--a-acc-d));
    color: #fff;
    box-shadow: 0 14px 30px -14px var(--a-acc);
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }

.btn-success {
    background: linear-gradient(135deg, #16a34a, #0f8a3e);
    color: #fff;
    box-shadow: 0 14px 30px -14px #16a34a;
}

.btn-success:hover:not(:disabled) { filter: brightness(1.06); }

.btn-light {
    background: #fff;
    color: #33445f;
    border: 1.5px solid var(--a-line);
}

.btn-light:hover:not(:disabled) {
    border-color: var(--a-acc);
    color: var(--a-acc-d);
    background: #f2f8ff;
}

.btn-sm {
    min-height: 50px;
    padding: 0 18px;
    font-size: .88rem;
    font-weight: 700;
}

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

.btn-light.btn-loading::after {
    border-color: rgba(30, 136, 229, .25);
    border-top-color: var(--a-acc);
}

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

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 700;
    color: #33445f;
    margin-bottom: 7px;
}

.form-label .required { color: var(--color-danger); }

.form-control {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    font-size: .95rem;
    font-family: inherit;
    border: 1px solid var(--a-line);
    border-radius: 12px;
    background: var(--a-field);
    color: var(--a-ink);
    transition: .15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--a-acc);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(30, 136, 229, .14);
}

.form-control::placeholder { color: #9aa7bb; }

textarea.form-control {
    height: auto;
    min-height: 96px;
    padding: 12px 14px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8.825L1.175 4 2.238 2.938 6 6.7 9.763 2.937 10.825 4z' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-hint {
    font-size: .76rem;
    color: var(--a-muted);
    margin-top: 5px;
}

/* ============================================================
   CODE BLOCK
   ============================================================ */
.code-block {
    background: #0f1b2e;
    color: #a5f3fc;
    padding: 14px 16px;
    border-radius: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: .76rem;
    line-height: 1.7;
    overflow-x: auto;
}

/* ============================================================
   COMPLETE VIEW (success animation)
   ============================================================ */
.complete-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.complete-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--a-ink);
    margin-bottom: 6px;
}

.complete-subtitle {
    font-size: .92rem;
    color: var(--a-muted);
    margin-bottom: 24px;
}

.complete-links {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.complete-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 22px;
    background: #fff;
    border: 1.5px solid var(--a-line);
    border-radius: 12px;
    color: #33445f;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 700;
    transition: all var(--transition);
}

.complete-link:hover {
    border-color: var(--a-acc);
    color: var(--a-acc-d);
    background: #f2f8ff;
}

/* ============================================================
   MIGRATE PAGE — Progress Bar & Console
   ============================================================ */
.progress-wrapper { margin-bottom: 16px; }

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .8rem;
    font-weight: 700;
    color: #4a5a73;
    margin-bottom: 7px;
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: var(--color-gray-100);
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--a-acc), var(--a-acc2));
    border-radius: 100px;
    transition: width .4s ease;
}

.console-log {
    background: #0f1b2e;
    color: #d1d9e6;
    padding: 14px 16px;
    border-radius: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: .74rem;
    max-height: 220px;
    overflow-y: auto;
    line-height: 1.8;
    display: none;
}

.log-line { color: #a5f3fc; }
.log-line.error { color: #fca5a5; }

.migrate-output {
    background: #0f1b2e;
    color: #d1d9e6;
    padding: 16px;
    border-radius: 12px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: .76rem;
    max-height: 240px;
    overflow-y: auto;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ============================================================
   HELPERS
   ============================================================ */
.hidden,
[hidden] { display: none !important; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }

hr {
    border: none;
    border-top: 1px solid var(--a-line);
}

/* Some steps set a near-white border colour inline for the old dark layout */
.installer-content hr { border-color: var(--a-line) !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .installer-box {
        grid-template-columns: 1fr;
        max-width: 640px;
        margin: 0 auto;
    }

    .installer-art { display: none; }

    /* The artwork would vanish on a phone: a wide strip above the form instead */
    .art-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 18px 24px 0;
    }

    .art-mobile img {
        display: block;
        width: auto;
        max-width: 48%;
        max-height: 104px;
        height: auto;
    }

    .wiz-dots { margin: 14px 24px 0; }
    .content-header { padding: 20px 24px 0; }
    .content-body { padding: 18px 24px; }
    .content-footer { padding: 14px 24px 20px; }
}

@media (max-width: 560px) {
    body.install-body { padding: 16px 10px; }

    .content-header h3 { font-size: 1.3rem; }

    .content-footer { flex-wrap: wrap; }
    .content-footer .btn { flex: 1 1 140px; }
    .complete-links { flex-direction: column; align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
    .installer-box,
    .content-header,
    .content-body,
    .pane { animation: none; }
}

/* ============================================================
   WELCOME PAGE: plain text, three short pages (Back / Continue)
   ============================================================ */
.pane { animation: wizIn .28s cubic-bezier(.2, .8, .25, 1) both; }
.pane[hidden] { display: none; }

.lead {
    margin: 0 0 12px;
    font-size: .92rem;
    line-height: 1.55;
    color: #41506a;
}

.kv { margin: 0; }

.kv > div {
    display: grid;
    grid-template-columns: 9.5rem 1fr;
    gap: 4px 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--a-line);
}

.kv > div:first-child { padding-top: 4px; }
.kv > div:last-child { border-bottom: 0; }
.kv dt { font-size: .82rem; font-weight: 700; color: #33445f; }
.kv dd { margin: 0; font-size: .9rem; line-height: 1.45; color: var(--a-ink); overflow-wrap: anywhere; }

.ok-t { color: #1a6b34; font-weight: 600; }
.warn-t { color: #8a5a00; font-weight: 600; }
.bad-t { color: #b3261e; font-weight: 600; }
.dim-t { color: var(--a-muted); }

.plain {
    margin: 0 0 14px 18px;
    padding: 0;
    font-size: .86rem;
    line-height: 1.5;
    color: #41506a;
}

.plain li { margin: 0 0 4px; }

/* Same box as the terms line of the account-creation form */
.terms-group {
    margin: 4px 0 0;
    padding: 13px 15px;
    background: var(--a-field);
    border: 1px solid var(--a-line);
    border-radius: 11px;
}

.terms-group label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.terms-group input { margin-top: 2px; width: 17px; height: 17px; cursor: pointer; accent-color: var(--a-acc); flex: 0 0 auto; }
.terms-group input:disabled { cursor: not-allowed; }
.terms-group span { font-size: 13px; color: #41506a; line-height: 1.5; }
.terms-group a { color: var(--a-acc); text-decoration: none; font-weight: 600; }
.terms-group a:hover { text-decoration: underline; }

.note { margin: 12px 0 0; font-size: .86rem; line-height: 1.5; }
.content-body > .note:first-child { margin: 0 0 16px; }

.foot-note { font-size: .78rem; color: var(--color-gray-400); font-variant-numeric: tabular-nums; }

/* Information messages on the other steps: plain text, no box, no icon */
.alert-info {
    background: none;
    border: 0;
    padding: 0;
    color: var(--a-muted);
}

.alert-info .alert-icon { display: none; }

/* ============================================================
   SINGLE-SCREEN MODE: the welcome page never scrolls
   ============================================================ */
@media (min-width: 901px) and (min-height: 540px) {
    body.install-body.is-fit {
        height: 100vh;
        min-height: 0;
        overflow: hidden;
        padding: 14px 16px;
    }

    .is-fit .install-wrapper { height: 100%; max-height: 760px; }
    .is-fit .installer-box { height: 100%; }
    .is-fit .installer-main { min-height: 0; }
    .is-fit .installer-content { min-height: 0; }
    .is-fit .content-body { min-height: 0; overflow: auto; scrollbar-width: thin; }

    .is-fit .installer-art { display: flex; align-items: center; justify-content: center; padding: 24px 28px; }
    .is-fit .art-stack { position: static; }
    .is-fit .installer-art img { width: auto; max-width: 100%; max-height: calc((min(100vh, 760px) - 28px - 48px - 18px) / 2); }
}

/* Buttons carry text only */
.btn svg { display: none; }

@media (min-width: 901px) and (max-height: 700px) {
    .is-fit .lead { margin-bottom: 8px; }
    .is-fit .plain { margin-bottom: 10px; }
    .is-fit .plain li { margin-bottom: 2px; }
    .is-fit .kv > div { padding: 8px 0; }
}

/* Database step: host/port and name/username side by side */
#databaseForm { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
#databaseForm > #messageBox { grid-column: 1 / -1; }
#databaseForm > .form-group:nth-of-type(5) { grid-column: 1 / -1; }

@media (max-width: 560px) {
    .kv > div { grid-template-columns: 1fr; }
    #databaseForm { grid-template-columns: 1fr; }
}
