@import url('/fonts/optiwp-fonts.css');

:root {
    /* OPTIWP — Swiss Precision Lab Design System */
    --bg: #f6f5f0;
    --surface: #ffffff;
    --surface-subtle: #efede6;
    --surface-canvas: #e5e3da;
    --border: #dcdad0;
    --border-mid: #b8b5a7;
    --border-strong: #0a0b0e;
    --ink: #0a0b0e;
    --ink-soft: #262932;
    --muted: #5a5d6b;
    --accent: #0047ff;
    --accent-hover: #0037cc;
    --accent-fg: #ffffff;
    --accent-tint: #eef3ff;
    --petrol: #1b6f93;

    /* Semantic Status Colors */
    --emerald: #047857;
    --emerald-bg: #ecfdf5;
    --emerald-border: #6ee7b7;
    --amber: #b45309;
    --amber-bg: #fffbeb;
    --amber-border: #fcd34d;
    --crimson: #be123c;
    --crimson-bg: #fff1f2;
    --crimson-border: #fda4af;

    /* Typography */
    --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Strict Orthogonal Shadows */
    --shadow-hard-sm: 2px 2px 0px #0a0b0e;
    --shadow-hard-md: 4px 4px 0px #0a0b0e;
    --shadow-hard-lg: 6px 6px 0px #0a0b0e;
    --shadow-frame: 6px 6px 0px rgba(10, 11, 14, 0.10);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border-radius: 0 !important;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--ink);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.5;
}

body.scrollable-page {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

code {
    font-family: var(--font-mono);
    font-size: 0.82em;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    padding: 1px 5px;
    color: var(--ink);
}

.icon-svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: square;
    stroke-linejoin: miter;
    fill: none;
    flex-shrink: 0;
}

/* =========================================================================
 * Brand Identity (Official OPTIWP Wordmark + Technical Tag)
 * ========================================================================= */
.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
}

.brand-logo-img {
    height: 26px;
    width: auto;
    display: block;
}

.brand-logo-lg {
    height: 32px;
    width: auto;
    display: block;
}

.brand-divider {
    width: 1px;
    height: 20px;
    background: var(--border-mid);
    display: inline-block;
}

.brand-tag {
    font-family: var(--font-mono);
    font-size: 0.70rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--surface-subtle);
    border: 1px solid var(--border-mid);
    padding: 3px 7px;
    white-space: nowrap;
}

/* =========================================================================
 * Controls, Inputs & Tactile Buttons (Zero Radius)
 * ========================================================================= */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    color: var(--ink-soft);
}

.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.input::placeholder {
    color: #8c8f9c;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
    background: #ffffff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    border: 1px solid var(--border-strong);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.12s ease, color 0.12s ease, transform 0.06s ease, box-shadow 0.06s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none !important;
    transform: none !important;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
    border: 1.5px solid var(--border-strong);
    box-shadow: var(--shadow-hard-sm);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px var(--border-strong);
}

.btn-ink {
    background: var(--ink);
    color: #ffffff;
    border: 1.5px solid var(--ink);
}

.btn-ink:hover:not(:disabled) {
    background: #22252e;
}

.btn-outline {
    background: var(--surface);
    border: 1px solid var(--border-mid);
    color: var(--ink);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--surface-subtle);
}

.btn-outline.is-active {
    background: var(--ink);
    color: #ffffff;
    border-color: var(--ink);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.70rem;
}

.btn-icon {
    padding: 9px 11px;
}

.btn-full {
    width: 100%;
    padding: 12px 16px;
}

.error-alert {
    background: var(--crimson-bg);
    color: var(--crimson);
    border: 1px solid var(--crimson-border);
    border-left: 3px solid var(--crimson);
    padding: 10px 12px;
    font-size: 0.84rem;
    font-weight: 500;
    margin-bottom: 16px;
}

/* =========================================================================
 * Login Screen — Architectural Grid Sheet
 * ========================================================================= */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-color: var(--bg);
    background-image:
        linear-gradient(to right, rgba(10, 11, 14, 0.045) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(10, 11, 14, 0.045) 1px, transparent 1px);
    background-size: 32px 32px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border: 1.5px solid var(--border-strong);
    box-shadow: var(--shadow-hard-lg);
}

.login-card-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 18px;
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.status-dot-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink);
}

.status-dot-inline::before {
    content: '';
    width: 7px;
    height: 7px;
    background: var(--emerald);
    display: inline-block;
}

.login-card-body {
    padding: 30px 28px 28px;
}

.login-brand-row {
    margin-bottom: 20px;
}

.login-card h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.18;
    margin-bottom: 8px;
    color: var(--ink);
}

.login-card p.subtitle {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* =========================================================================
 * Topbar Navigation (Client Studio & Admin)
 * ========================================================================= */
.studio-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar-nav {
    height: 56px;
    background: var(--surface);
    border-bottom: 1.5px solid var(--border-strong);
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-select {
    padding: 6px 12px;
    border: 1px solid var(--border-strong);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.86rem;
    background: var(--bg);
    color: var(--ink);
    min-width: 230px;
    cursor: pointer;
}

.site-select:focus {
    outline: none;
    border-color: var(--accent);
}

.quota-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--border-mid);
    padding: 5px 11px;
    font-family: var(--font-mono);
    font-size: 0.71rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.quota-bar-track {
    width: 64px;
    height: 6px;
    background: var(--surface);
    border: 1px solid var(--border-mid);
    overflow: hidden;
}

.quota-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.2s ease;
}

.quota-bar-fill.warn {
    background: var(--amber);
}

.quota-bar-fill.full {
    background: var(--crimson);
}

.user-ident {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 4px;
}

/* =========================================================================
 * Split-Screen Workspace: Editorial Console (Left) + Live Web (Right)
 * ========================================================================= */
.studio-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 470px 1fr;
    min-height: 0;
}

.chat-pane {
    background: var(--bg);
    border-right: 1.5px solid var(--border-strong);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.quick-prompts {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    flex-shrink: 0;
}

.quick-prompts-label {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: 2px;
    white-space: nowrap;
}

.chip {
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--border-mid);
    color: var(--ink);
    padding: 4px 9px;
    font-family: var(--font-mono);
    font-size: 0.69rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.chip:hover {
    border-color: var(--border-strong);
    background: var(--ink);
    color: #ffffff;
}

/* Editorial Feed Messages */
.messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.89rem;
    line-height: 1.55;
    color: var(--ink);
    word-wrap: break-word;
}

.msg p + p {
    margin-top: 8px;
}

.msg-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--surface-subtle);
    font-family: var(--font-mono);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
}

.msg-user {
    background: var(--surface-subtle);
    border-color: var(--border-mid);
    border-left: 3px solid var(--ink);
}

.msg-user .msg-meta {
    border-bottom-color: var(--border);
    color: var(--ink-soft);
}

.msg-assistant {
    background: var(--surface);
    border-color: var(--border);
    border-left: 3px solid var(--accent);
}

.msg-assistant .msg-meta-role {
    color: var(--accent);
}

/* Mutation Specification Card (Diff + Confirm / Undo) */
.mutation-card {
    margin-top: 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
}

.mutation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.84rem;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.status-tag {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    padding: 2px 7px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid currentColor;
    white-space: nowrap;
}

.status-proposed {
    background: var(--amber-bg);
    color: var(--amber);
    border-color: var(--amber-border);
}

.status-applied {
    background: var(--emerald-bg);
    color: var(--emerald);
    border-color: var(--emerald-border);
}

.status-reverted {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--border-mid);
}

.diff-item {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 9px 12px;
    font-size: 0.81rem;
}

.diff-item:last-of-type {
    border-bottom: none;
}

.diff-target {
    font-family: var(--font-mono);
    font-size: 0.70rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 5px;
}

.diff-row {
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 8px;
    align-items: baseline;
    padding: 2px 0;
}

.diff-key {
    font-family: var(--font-mono);
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
}

.diff-before {
    color: #7c808f;
    text-decoration: line-through;
}

.diff-after {
    color: var(--ink);
    font-weight: 600;
    background: var(--accent-tint);
    padding: 1px 5px;
    border-left: 2px solid var(--accent);
}

.mutation-actions {
    padding: 10px 12px;
    background: var(--surface-subtle);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

/* Composer */
.composer {
    padding: 12px 14px;
    border-top: 1.5px solid var(--border-strong);
    background: var(--surface);
}

.attachment-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--accent-tint);
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.composer-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.composer textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    padding: 9px 11px;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--ink);
    max-height: 120px;
    line-height: 1.45;
}

.composer textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
    background: var(--surface);
}

/* =========================================================================
 * Right Column: Live Website Viewport
 * ========================================================================= */
.preview-pane {
    display: flex;
    flex-direction: column;
    background: var(--surface-canvas);
    min-height: 0;
}

.preview-toolbar {
    height: 44px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.viewport-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.url-bar {
    flex: 1;
    max-width: 520px;
    background: var(--bg);
    border: 1px solid var(--border-mid);
    padding: 5px 10px;
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.74rem;
}

.preview-stage {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: stretch;
    padding: 16px;
    overflow: hidden;
    background-color: var(--surface-canvas);
    background-image:
        linear-gradient(to right, rgba(10, 11, 14, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(10, 11, 14, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: 1.5px solid var(--border-strong);
    background: #ffffff;
    box-shadow: var(--shadow-frame);
    transition: width 0.22s ease;
}

.preview-frame.mobile-mode {
    width: 390px;
}

/* =========================================================================
 * Administration Console (/admin.html)
 * ========================================================================= */
.admin-container {
    max-width: 1200px;
    margin: 28px auto;
    padding: 0 22px 64px;
}

.admin-page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-mid);
}

.admin-page-header h1 {
    font-family: var(--font-display);
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--ink);
}

.admin-page-header span {
    font-family: var(--font-mono);
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-top: 3px solid var(--ink);
    padding: 16px 18px;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.70rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.panel-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    padding: 24px;
    margin-bottom: 24px;
}

.panel-section-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}

.section-index {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.06em;
}

.panel-card h2 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--ink);
}

.panel-lead {
    font-size: 0.86rem;
    color: var(--muted);
    margin-bottom: 18px;
    line-height: 1.55;
}

.notice-banner {
    display: inline-block;
    padding: 7px 12px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    border: 1px solid var(--border-mid);
}

.notice-banner.ok {
    background: var(--emerald-bg);
    color: var(--emerald);
    border-color: var(--emerald-border);
    border-left: 3px solid var(--emerald);
}

.notice-banner.warn {
    background: var(--amber-bg);
    color: var(--amber);
    border-color: var(--amber-border);
    border-left: 3px solid var(--amber);
}

.notice-banner.err {
    background: var(--crimson-bg);
    color: var(--crimson);
    border-color: var(--crimson-border);
    border-left: 3px solid var(--crimson);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--surface-subtle);
    color: var(--ink-soft);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.70rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-mid);
}

.data-table td {
    font-variant-numeric: tabular-nums;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
}

@media (max-width: 980px) {
    .studio-grid {
        grid-template-columns: 1fr;
    }
    .preview-pane {
        display: none;
    }
    .topbar-nav {
        height: auto;
        padding: 10px 14px;
        flex-wrap: wrap;
    }
}
