/* Stage 21 final UI polish. Readable, non-minified CSS. */
:root {
    --final-page-gap: 1.5rem;
    --final-card-padding: 1.35rem;
    --final-input-height: 42px;
}

body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.button,
button,
input,
select,
textarea {
    font-family: var(--font-sans);
}

.button {
    box-shadow: none;
    white-space: nowrap;
}

.button-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.button-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.card,
.section-card,
.hero-preview,
.stats-row article,
.feature-grid article,
.step-list article,
.cta-section,
.auth-card,
.operator-card,
.widget-preview-card,
.billing-plan-card,
.billing-inline-note,
.project-status-card {
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-card);
}

.card:hover,
.feature-grid article:hover,
.stats-row article:hover,
.billing-plan-card:hover {
    transform: translateY(-1px);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.input,
select.input,
textarea.input {
    min-height: var(--final-input-height);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
}

textarea.input {
    min-height: 110px;
}

.input:focus,
select.input:focus,
textarea.input:focus {
    outline: 0;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem rgba(59, 125, 221, 0.16);
}

label {
    color: var(--color-heading);
    font-weight: 600;
}

.page-note,
.muted,
.text-muted {
    color: var(--color-muted);
}

.alert {
    border-radius: var(--radius-default);
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(28, 187, 140, 0.12);
    border-color: rgba(28, 187, 140, 0.3);
    color: var(--color-success);
}

.alert-warning {
    background: rgba(252, 185, 44, 0.13);
    border-color: rgba(252, 185, 44, 0.36);
    color: #a16b00;
}

html[data-theme="dark"] .alert-warning {
    color: #f4c76a;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.12);
    border-color: rgba(220, 53, 69, 0.3);
    color: var(--color-danger);
}

.public-header {
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
}

.public-nav .button-primary:hover {
    color: #ffffff;
}

.public-body .hero {
    position: relative;
}

.public-body .hero::before {
    content: "";
    position: absolute;
    inset: 1.5rem 2rem auto auto;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: var(--color-primary-soft);
    filter: blur(26px);
    opacity: 0.7;
    pointer-events: none;
}

.hero-content,
.hero-preview {
    position: relative;
    z-index: 1;
}

.hero h1,
.page-hero h1 {
    font-weight: 400;
}

.feature-grid article,
.step-list article,
.stats-row article,
.billing-plan-card {
    overflow: hidden;
}

.feature-grid article h2,
.feature-grid article h3,
.billing-plan-card h3 {
    font-weight: 600;
}

.plan-price strong,
.stats-row strong {
    letter-spacing: -0.03em;
}

.public-footer {
    border-top: 1px solid var(--color-border);
}

.auth-page {
    background: var(--color-background);
}

.auth-shell .brand {
    justify-content: center;
    margin-bottom: 1.2rem;
}

.auth-card,
.auth-shell form,
.auth-shell .card {
    background: var(--color-surface);
    border-radius: var(--radius-default);
}

.topbar {
    border-bottom: 1px solid var(--color-border);
}

.content {
    padding-bottom: 3rem;
}

.page-head {
    align-items: flex-start;
}

.page-head h1 {
    font-size: 1.55rem;
}

.actions,
.form-actions,
.navbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.table-wrap,
.table-responsive {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-default);
}

.table-wrap table,
.table-responsive table {
    margin-bottom: 0;
}

.widget-settings-grid,
.embed-builder-grid,
.final-widget-builder-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
    gap: var(--final-page-gap);
    align-items: start;
}

.widget-preview-sticky {
    position: sticky;
    top: 88px;
}

.widget-preview-card {
    overflow: hidden;
}

.widget-preview-stage {
    position: relative;
    min-height: 430px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-default);
    background: var(--color-surface-soft);
    padding: 1rem;
}

.preview-chat-window {
    position: absolute;
    right: 1.25rem;
    bottom: 5rem;
    width: min(320px, calc(100% - 2.5rem));
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-default);
    background: var(--color-surface);
    box-shadow: 0 1rem 2.25rem rgba(33, 37, 41, 0.16);
}

.widget-preview-stage[data-position="left"] .preview-chat-window {
    right: auto;
    left: 1.25rem;
}

.preview-chat-header {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    background: var(--color-primary);
    color: #ffffff;
    padding: 0.85rem 1rem;
}

.preview-chat-header strong,
.preview-chat-header span {
    color: #ffffff;
}

.preview-chat-body {
    display: grid;
    gap: 0.65rem;
    padding: 1rem;
}

.preview-message.support,
.preview-message.visitor {
    border-radius: var(--radius-default);
    padding: 0.65rem 0.75rem;
}

.preview-message.support {
    background: var(--color-surface-soft);
    color: var(--color-text);
}

.preview-message.visitor {
    justify-self: end;
    background: var(--color-primary);
    color: #ffffff;
}

.preview-branding {
    border-top: 1px solid var(--color-border);
    padding: 0.65rem 1rem;
    color: var(--color-muted);
    font-size: 0.78rem;
    text-align: center;
}

.preview-launcher {
    position: absolute;
    right: 1.25rem;
    bottom: 1.25rem;
    min-height: 46px;
    border: 0;
    border-radius: var(--radius-default);
    background: var(--color-primary);
    color: #ffffff;
    padding: 0 1.1rem;
    font-weight: 600;
    box-shadow: 0 0.65rem 1.25rem rgba(59, 125, 221, 0.26);
}

.widget-preview-stage[data-position="left"] .preview-launcher {
    right: auto;
    left: 1.25rem;
}

.feature-gate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid rgba(59, 125, 221, 0.28);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-default);
    background: var(--color-primary-soft);
    color: var(--color-heading);
    padding: 0.85rem 1rem;
    margin: 0.85rem 0;
}

.feature-gate strong {
    font-weight: 600;
}

.feature-gate-wide {
    grid-column: 1 / -1;
}

.plan-locked-field {
    opacity: 0.72;
}

.final-plan-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    padding: 0.15rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
}

.code-box {
    min-height: 140px;
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
}

.menu-badge {
    margin-left: auto;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--color-danger);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
}

@media (max-width: 991px) {
    .widget-settings-grid,
    .embed-builder-grid,
    .final-widget-builder-grid,
    .hero-large,
    .split-section {
        grid-template-columns: 1fr;
    }

    .widget-preview-sticky {
        position: static;
    }

    .public-header {
        padding: 0 1rem;
    }
}

@media (max-width: 767px) {
    .content {
        padding: 1rem;
    }

    .page-head,
    .billing-inline-note,
    .project-status-card,
    .domain-item,
    .feature-gate {
        flex-direction: column;
        align-items: stretch;
    }

    .form-grid,
    .check-grid,
    .two-column,
    .stats-row,
    .feature-grid,
    .billing-plan-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-width: 76px;
        width: 76px;
    }

    .sidebar-brand span,
    .sidebar-link span:not(.sidebar-icon),
    .sidebar-header {
        display: none;
    }

    .sidebar-link {
        justify-content: center;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}
