/* ==========================================================================
   GODZLY — EDITORIAL APPLICATION SURFACES
   --------------------------------------------------------------------------
   The client dashboard and the server designer are information-dense product
   screens, not marketing pages. They inherit the palette, the display face and
   the squared controls from editorial.css, but keep a tighter rhythm, smaller
   type and stronger states.

   Loaded after style.css and editorial.css. No markup, id, listener or data
   path is changed here — only the shipped appearance.
   ========================================================================== */

/* The marketing footer sits after </main> in the document, so when the client
   dashboard is revealed it would otherwise appear ABOVE the dashboard. It has
   no place on an authenticated route; the designer is a fixed overlay and
   covers it anyway. */
body.dashboard-route .glass-footer,
body:has(#dashboard-view:not(.hidden)) .glass-footer {
    display: none;
}

/* ==========================================================================
   1. CLIENT DASHBOARD
   ========================================================================== */
.dashboard-wrapper {
    display: flex;
    align-items: flex-start;
    gap: clamp(1rem, 2vw, 1.75rem);
    width: 100%;
    max-width: 1240px;
    margin-inline: auto;
    padding-top: 7.25rem;
    padding-bottom: 3rem;
}

.dashboard-sidebar {
    position: sticky;
    top: 6.5rem;
    width: 250px;
    flex-shrink: 0;
    height: fit-content;
    padding: 1.5rem 1.25rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-md);
    background: var(--ed-white);
    box-shadow: none;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.15rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid var(--ed-line);
}

.sidebar-user img,
.avatar-glow {
    width: 40px;
    height: 40px;
    border: 1px solid var(--ed-line);
    border-radius: 50%;
    background: var(--ed-sage);
    object-fit: cover;
}

.sidebar-user-info h4 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 440;
    letter-spacing: -0.02em;
    color: var(--ed-ink);
}

.user-role {
    display: block;
    margin-top: 0.15rem;
    font-family: var(--font-mono);
    font-size: 0.56rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ed-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.62rem 0.7rem;
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--ed-muted);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 450;
    text-align: left;
    transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.sidebar-link i {
    font-size: 0.95rem;
}

.sidebar-link:hover {
    background: var(--ed-paper-warm);
    color: var(--ed-ink);
}

.sidebar-link.active {
    border-left-color: var(--ed-emerald);
    background: var(--ed-sage-soft);
    color: var(--ed-emerald-deep);
    font-weight: 560;
}

.dashboard-main {
    flex: 1;
    min-width: 0;
    min-height: 520px;
    padding: clamp(1.25rem, 2.5vw, 2.25rem);
    border: 1px solid var(--ed-line);
    border-radius: var(--r-md);
    background: var(--ed-white);
    box-shadow: none;
}

.dashboard-section {
    display: none;
}

.dashboard-section.active {
    display: block;
    animation: ed-app-in 280ms var(--ease);
}

@keyframes ed-app-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.dashboard-section > .section-title {
    margin: 0 0 1.5rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--ed-ink);
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.4vw, 1.8rem);
    font-weight: 420;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

/* The overview's injected subscription banner keeps its node, loses the pill. */
#active-subscription-container > div {
    border-radius: var(--r-xs) !important;
    border-color: var(--ed-line) !important;
    background: var(--ed-paper) !important;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

.orders-grid,
.orders-list,
.invoices-grid {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.order-card,
.invoice-card {
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-sm);
    background: var(--ed-paper);
    box-shadow: none;
}

.order-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.order-id {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    color: var(--ed-muted-soft);
}

.order-card h4 {
    margin: 0.2rem 0 0.55rem;
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 560;
    letter-spacing: 0;
    color: var(--ed-ink);
}

.order-status,
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.16rem 0.45rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-xs);
    background: transparent;
    font-family: var(--font-mono);
    font-size: 0.56rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ed-muted);
}

.status-pending { color: var(--ed-warning); }
.status-progress { color: var(--ed-emerald-deep); border-color: rgba(8, 125, 89, 0.3); }
.status-testing { color: #0E6478; border-color: rgba(14, 100, 120, 0.28); }
.status-completed { color: var(--ed-emerald-deep); border-color: rgba(8, 125, 89, 0.3); }

.order-progress-bar {
    height: 3px;
    margin-top: 0.35rem;
    border-radius: 0;
    background: var(--ed-line-soft);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 0;
    background: var(--ed-emerald);
    transition: width 500ms var(--ease);
}

.invoice-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.invoice-info h4 {
    margin: 0 0 0.2rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 560;
    letter-spacing: 0;
}

.invoice-card .btn {
    flex-shrink: 0;
}

/* ── Tickets ─────────────────────────────────────────────────────────────── */
.tickets-layout {
    display: grid;
    grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
    gap: 1rem;
}

.tickets-sidebar {
    padding: 1rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-sm);
    background: var(--ed-paper);
    max-height: 520px;
    overflow-y: auto;
}

.tickets-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ticket-item {
    padding: 0.8rem 0.75rem;
    border: 1px solid transparent;
    border-top-color: var(--ed-line-soft);
    border-radius: 0;
    cursor: pointer;
    transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.ticket-item:first-child {
    border-top-color: transparent;
}

.ticket-item:hover {
    background: var(--ed-white);
    border-color: var(--ed-line);
}

.ticket-item strong {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 550;
}

.ticket-chat {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.15rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-sm);
    background: var(--ed-white);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--ed-line);
}

.chat-header h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 440;
    letter-spacing: -0.02em;
}

.chat-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 340px;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.chat-msg {
    max-width: 86%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--ed-line-soft);
    border-radius: var(--r-sm);
    background: var(--ed-paper);
}

.msg-user {
    align-self: flex-end;
    border-color: rgba(8, 125, 89, 0.22);
    background: rgba(8, 125, 89, 0.07);
}

.msg-admin {
    align-self: flex-start;
    background: var(--ed-white);
}

.msg-content {
    color: var(--ed-ink-soft);
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--ed-line);
}

.chat-input-area input {
    flex: 1;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-sm);
    background: var(--ed-paper);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--ed-ink);
}

.chat-input-area input:focus {
    outline: none;
    border-color: var(--ed-emerald);
}

.chat-input-area .btn-icon {
    border: 1px solid var(--ed-line);
    border-radius: var(--r-sm);
}

/* ==========================================================================
   2. DESIGNER
   ========================================================================== */
.designer-wrapper {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--ed-paper);
    color: var(--ed-ink);
}

.designer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
    padding: 0.9rem clamp(1rem, 3vw, 1.75rem);
    border: 0;
    border-bottom: 1px solid var(--ed-line);
    border-radius: 0;
    background: var(--ed-white);
    box-shadow: none;
    backdrop-filter: none;
    z-index: 10;
}

.designer-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.designer-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-size: 1.12rem;
    font-weight: 460;
    letter-spacing: -0.02em;
    color: var(--ed-ink);
}

.designer-brand i {
    font-size: 1.05rem;
    color: var(--ed-emerald);
}

.designer-header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.designer-breadcrumb {
    display: inline-block;
    padding: 0.28rem 0.6rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-xs);
    background: transparent;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ed-muted);
}

.designer-header-right {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.designer-header .btn {
    min-height: 2.35rem;
    padding: 0.5rem 0.8rem;
    font-size: 0.75rem;
}

.designer-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.designer-sidebar {
    display: flex;
    flex-direction: column;
    width: 292px;
    flex-shrink: 0;
    padding: 1.25rem;
    overflow-y: auto;
    border: 0;
    border-right: 1px solid var(--ed-line);
    border-radius: 0;
    background: var(--ed-white);
    box-shadow: none;
}

.designer-sidebar-title,
.designer-summary-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ed-muted);
}

.designer-sidebar-title i,
.designer-summary-title i {
    font-size: 0.85rem;
    color: var(--ed-emerald);
}

.designer-divider {
    height: 1px;
    margin: 0.35rem 0;
    background: var(--ed-line-soft);
}

.designer-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.4rem 0.75rem;
    text-align: center;
    border: 1px dashed var(--ed-line);
    border-radius: var(--r-sm);
}

.designer-empty-state i {
    font-size: 1.35rem;
    color: var(--ed-muted-soft);
    opacity: 0.65;
}

.designer-empty-state p {
    margin: 0;
    font-size: 0.72rem;
    color: var(--ed-muted);
}

.designer-preview {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.25rem;
    padding: 2rem;
    overflow: auto;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-sm);
    background:
        linear-gradient(90deg, rgba(20, 26, 23, 0.035) 1px, transparent 1px) 0 0 / 28px 28px,
        linear-gradient(rgba(20, 26, 23, 0.035) 1px, transparent 1px) 0 0 / 28px 28px,
        var(--ed-white);
    box-shadow: none;
}

.designer-preview-empty {
    max-width: 380px;
    text-align: center;
}

.designer-preview-icon {
    display: grid;
    place-items: center;
    width: 3.2rem;
    height: 3.2rem;
    margin: 0 auto 1.25rem;
    border: 1px solid var(--ed-line);
    border-radius: 50%;
    color: var(--ed-emerald-deep);
    font-size: 1.4rem;
}

.designer-preview-empty h3 {
    margin: 0 0 0.4rem;
    font-family: var(--font-display);
    font-size: 1.65rem;
    font-weight: 420;
    letter-spacing: -0.03em;
}

.designer-preview-empty p {
    margin: 0 0 1rem;
    font-size: 0.84rem;
    line-height: 1.65;
    color: var(--ed-muted);
}

.designer-preview-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ed-muted-soft);
}

.designer-summary {
    display: flex;
    flex-direction: column;
    width: 320px;
    flex-shrink: 0;
    padding: 1.25rem;
    overflow-y: auto;
    border: 0;
    border-left: 1px solid var(--ed-line);
    border-radius: 0;
    background: var(--ed-white);
    box-shadow: none;
}

.designer-summary-section {
    padding: 0.5rem 0;
}

.designer-summary-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

.designer-stat-item {
    padding: 0.7rem;
    border: 1px solid var(--ed-line-soft);
    border-radius: var(--r-xs);
    background: var(--ed-paper);
}

.designer-stat-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.54rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ed-muted-soft);
}

.designer-stat-value {
    display: block;
    margin-top: 0.2rem;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 420;
    line-height: 1;
}

.designer-summary-export {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.designer-summary-export .btn {
    width: 100%;
    min-height: 2.35rem;
    font-size: 0.72rem;
}

.designer-sidebar-hint {
    font-size: 0.7rem;
    line-height: 1.55;
    color: var(--ed-muted);
}

/* Generated configuration state (designer.js) */
.designer-config-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.designer-config-tag,
.designer-config-selected {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.45rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-xs);
    background: transparent;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.04em;
    color: var(--ed-muted);
}

.designer-config-tag.accent {
    border-color: rgba(8, 125, 89, 0.32);
    color: var(--ed-emerald-deep);
}

.designer-type-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.designer-type-card {
    padding: 0.75rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-sm);
    background: var(--ed-paper);
    transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}

.designer-type-card:hover {
    border-color: var(--ed-line-strong);
}

.designer-type-card.selected {
    border-color: var(--ed-emerald);
    background: rgba(8, 125, 89, 0.06);
}

.designer-type-icon {
    color: var(--ed-emerald-deep);
    font-size: 1rem;
}

.designer-type-label {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.72rem;
    font-weight: 560;
    color: var(--ed-ink);
}

.designer-type-desc {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.64rem;
    line-height: 1.45;
    color: var(--ed-muted);
}

.designer-feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.designer-feature-card {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem;
    border: 1px solid var(--ed-line-soft);
    border-radius: var(--r-xs);
    background: transparent;
}

.designer-feature-icon {
    color: var(--ed-emerald-deep);
}

.designer-feature-label {
    font-size: 0.68rem;
    color: var(--ed-ink-soft);
}

.designer-generation-panel {
    padding: 1rem;
    border: 1px solid var(--ed-line);
    border-radius: var(--r-sm);
    background: var(--ed-paper);
}

.designer-generation-kicker {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ed-muted);
}

.designer-generation-heading {
    margin: 0.35rem 0 0.75rem;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 440;
}

.designer-generation-progress {
    height: 3px;
    border-radius: 0;
    background: var(--ed-line-soft);
    overflow: hidden;
}

.designer-generation-progress-fill {
    height: 100%;
    border-radius: 0;
    background: var(--ed-emerald);
}

.designer-generation-stages {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.65rem;
}

.designer-generation-stage {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.02em;
    color: var(--ed-muted);
}

.designer-generation-stage-marker {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--ed-line-strong);
}

.designer-generation-stage.active .designer-generation-stage-marker {
    background: var(--ed-emerald);
}

.designer-generate-btn {
    width: 100%;
    margin-top: 0.6rem;
}

/* ==========================================================================
   3. RESPONSIVE
   ========================================================================== */
@media (max-width: 1000px) {
    .dashboard-wrapper {
        flex-direction: column;
        padding-top: 6rem;
    }

    .dashboard-sidebar {
        position: static;
        width: 100%;
        padding: 1rem;
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        gap: 0.25rem;
        padding-bottom: 0.15rem;
    }

    .sidebar-link {
        width: auto;
        flex: 0 0 auto;
        border-left: 0;
        border-bottom: 2px solid transparent;
        padding: 0.5rem 0.7rem;
        white-space: nowrap;
    }

    .sidebar-link.active {
        border-bottom-color: var(--ed-emerald);
        background: transparent;
    }

    .dashboard-main {
        width: 100%;
    }

    /* Three fixed columns (292 + preview + 320) no longer fit, and squeezing
       the sidebar to 246px clipped every server-type label to ~30px. The body
       becomes a wrapping row instead: the rail and the preview share the first
       line at usable widths, and the summary — which holds the export actions
       — takes a full-width line of its own rather than being hidden. The
       explicit row direction undoes the legacy column rule in style.css. */
    .designer-body {
        flex-direction: row;
        flex-wrap: wrap;
        align-content: flex-start;
        overflow-y: auto;
    }

    .designer-sidebar {
        width: 292px;
        max-height: none;
    }

    .designer-preview {
        flex: 1 1 340px;
        min-width: 0;
    }

    .designer-summary {
        flex: 0 0 100%;
        width: 100%;
        order: 3;
        border-top: 1px solid var(--ed-line);
        border-left: 0;
    }

    .designer-header-center {
        display: none;
    }
}

@media (max-width: 760px) {
    .tickets-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .tickets-sidebar {
        max-height: 260px;
    }

    .dashboard-main {
        padding: 1.1rem;
    }

    .order-card,
    .invoice-card {
        padding: 1rem;
    }

    .invoice-card {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Below the rail layout the designer is a single scrolling column:
       server type, preview, then configuration/export. */
    .designer-body {
        flex-direction: column;
        flex-wrap: nowrap;
        overflow-y: auto;
    }

    .designer-sidebar {
        width: 100%;
        max-height: none;
        overflow-y: visible;
        padding: 0.9rem;
        border-right: 0;
        border-bottom: 1px solid var(--ed-line);
    }

    /* The configuration summary carries the JSON / copy export actions, so it
       stays available as a stacked panel rather than being hidden on mobile. */
    .designer-summary {
        display: flex;
        flex: 0 0 auto;
        width: 100%;
        order: 3;
    }

    .designer-preview {
        margin: 0.75rem;
        padding: 1.1rem;
    }

    .designer-header {
        padding: 0.7rem 0.9rem;
    }

    .designer-brand {
        font-size: 1rem;
    }

    .designer-header-right .btn {
        padding-inline: 0.6rem;
    }
}

@media (max-width: 560px) {
    .dashboard-wrapper {
        padding-top: 5.6rem;
    }

    .sidebar-nav {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .sidebar-link {
        font-size: 0.75rem;
    }


    .designer-summary {
        flex: 0 0 auto;
        order: 3;
    }

    .designer-preview {
        min-height: 48vh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .designer-header-right .btn span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dashboard-section.active {
        animation: none;
    }
}
