/* AI Systems — dark theme stylesheet (shares TechToday design tokens) */

:root {
    --bg: #121212;
    --bg-elevated: #1e1e1e;
    --bg-elevated-2: #2a2a2a;
    --border: #2c2c2c;
    --text: #e0e0e0;
    --text-muted: #9e9e9e;
    --text-faint: #757575;
    --accent: #90caf9;
    --primary: #1565c0;
    --primary-hover: #1976d2;
    --danger: #ef9a9a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: 90%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header / Nav */

header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(18, 18, 18, 0.9);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text);
}

.brand:hover {
    text-decoration: none;
}

.brand .logo {
    width: 24px;
    height: 24px;
    display: inline-block;
    background: url('logo.svg') no-repeat center / contain;
    flex-shrink: 0;
}

.nav-back-link {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.nav-back-link:hover,
.nav-back-link:focus-visible {
    color: var(--accent);
    text-decoration: none;
}

/* Hero */

.hero {
    padding: 0.65rem 0;
    text-align: left;
}

.hero .container {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 0.75rem;
}

.hero h1 {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.3;
}

.hero .subtitle {
    color: var(--text-faint);
    font-size: 0.8125rem;
    margin: 0;
    white-space: nowrap;
}

.hero .subtitle::before {
    content: "\2022";
    margin-right: 0.75rem;
    color: var(--border);
}

/* Sections */

section {
    padding: 0.75rem 0;
}

/* Cards grid */

.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.25rem;
    counter-reset: project-card;
}

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    counter-increment: project-card;
    min-width: 0;
}

/* A card that spans half the grid (2 of 4 columns). */
.card-half {
    grid-column: span 2;
}

/* A card that spans all columns. */
.card-wide {
    grid-column: 1 / -1;
}

.card h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    min-width: 0;
}

.card h2::before {
    content: counter(project-card);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border: 1px solid #4caf50;
    border-radius: 50%;
    color: #ff9800;
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1;
}

.info-link {
    position: relative;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 1rem;
    line-height: 1;
    color: #4caf50;
    /* green by default */
}

.info-link:hover {
    color: #ff9800;
    /* orange on hover */
    text-decoration: none;
}

.info-link::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 135%;
    right: 0;
    white-space: nowrap;
    background: var(--bg-elevated-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.6875rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
    z-index: 20;
}

.info-link:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.card p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.card p code {
    background: var(--bg-elevated-2);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.75rem;
    color: var(--accent);
}

/* Form controls */

input[type="text"],
textarea {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid #424242;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text);
    background: transparent;
    outline: none;
}

textarea {
    resize: vertical;
    line-height: 1.5;
}

input[type="text"]::placeholder,
textarea::placeholder {
    color: #616161;
}

input[type="text"]:focus,
textarea:focus {
    border-bottom-color: var(--accent);
}

.model-select-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: -0.2rem;
    margin-bottom: 0.1rem;
    min-width: 0;
    width: 100%;
}

.model-select-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    flex-shrink: 0;
}

.model-select {
    background: var(--bg-elevated-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 0.8125rem;
    color: var(--text);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease;
    min-width: 0;
    max-width: 100%;
    flex: 1;
}

.model-select:focus,
.model-select:hover {
    border-color: var(--accent);
}

/* Several labelled dropdowns side by side, wrapping on narrow cards. */
.select-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.select-row .model-select-wrap {
    width: auto;
    flex: 1 1 220px;
    margin: 0;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

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

button:active {
    box-shadow: none;
}

button:disabled {
    background: #424242;
    color: var(--text-faint);
    cursor: not-allowed;
    box-shadow: none;
}

/* Results */

.result {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
    background: transparent;
    border-left: none;
    padding: 0;
    white-space: normal;
    display: none;
    margin-top: 0.25rem;
}

.result.visible {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Output UI Components */

.output-card {
    background: var(--bg-elevated-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color 0.15s ease;
}

.output-card:hover {
    border-color: #424242;
}

.output-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.output-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.output-subcard {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 5px;
    padding: 0.65rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

/* Badges & Pills */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1.3;
}

.badge-success {
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.35);
}

.badge-danger {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.35);
}

.badge-warning {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.35);
}

.badge-info {
    background: rgba(33, 150, 243, 0.15);
    color: #90caf9;
    border: 1px solid rgba(33, 150, 243, 0.35);
}

.badge-neutral {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.72rem;
}

/* KPI Dashboard Row */

.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (max-width: 650px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    background: var(--bg-elevated-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.kpi-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-subtext {
    font-size: 0.72rem;
    color: var(--text-faint);
}

/* Status Banner */

.status-banner {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border-left: 4px solid var(--primary);
    background: var(--bg-elevated-2);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.status-banner-danger {
    border-left-color: #f44336;
    background: rgba(244, 67, 54, 0.08);
}

.status-banner-success {
    border-left-color: #4caf50;
    background: rgba(76, 175, 80, 0.08);
}

.status-banner-title {
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.status-banner-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Chat Thread & Bubbles */

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.chat-round {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.chat-round-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-round-body {
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.chat-msg-user {
    background: rgba(144, 202, 249, 0.06);
    border-left: 3px solid var(--accent);
    padding: 0.5rem 0.75rem;
    border-radius: 0 5px 5px 0;
}

.chat-msg-model {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid #66bb6a;
    padding: 0.5rem 0.75rem;
    border-radius: 0 5px 5px 0;
}

.chat-sender {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-msg-user .chat-sender {
    color: var(--accent);
}

.chat-msg-model .chat-sender {
    color: #81c784;
}

.verdict-callout {
    margin-top: 0.35rem;
    padding: 0.4rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Collapsible Reasoning Trace & Markdown Formatting */

.reasoning-details {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.reasoning-details summary {
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 6px 14px;
    background: rgba(144, 202, 249, 0.08);
    border: 1px solid rgba(144, 202, 249, 0.25);
    border-radius: 5px;
    font-size: 0.82rem;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.reasoning-details summary:hover {
    text-decoration: none;
    background: rgba(144, 202, 249, 0.16);
    border-color: rgba(144, 202, 249, 0.45);
}

.reasoning-details[open]>summary {
    background: rgba(144, 202, 249, 0.18);
    border-color: var(--accent);
}

.reasoning-content {
    margin-top: 0.65rem;
    padding: 1.25rem 1.4rem;
    background: #090e18;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    font-size: 0.9375rem;
    line-height: 1.75;
    color: #e2e8f0;
    max-height: 480px;
    overflow-y: auto;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.reasoning-content p {
    margin: 0 0 0.95rem;
    color: #e2e8f0;
    font-size: 0.9375rem;
    line-height: 1.75;
}

.reasoning-content p:last-child {
    margin-bottom: 0;
}

.reasoning-content strong {
    color: #ffffff;
    font-weight: 600;
}

.reasoning-content em {
    color: #ffb74d;
    font-style: italic;
}

.reasoning-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 1rem 0 0.5rem;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 2px;
}

.step-text {
    flex: 1;
    font-size: 0.95rem;
    color: #f8fafc;
    font-weight: 600;
    line-height: 1.6;
}

.step-text strong {
    color: #ffffff;
}

.reasoning-bullets {
    margin: 0.4rem 0 0.95rem 1.5rem;
    padding: 0;
    list-style-type: disc;
}

.reasoning-bullets li {
    margin-bottom: 0.45rem;
    line-height: 1.7;
    color: #cbd5e1;
    font-size: 0.9375rem;
}

.reasoning-bullets li::marker {
    color: #94a3b8;
}

.math-display,
.katex-display {
    background: transparent;
    border: none;
    padding: 0.15rem 0 0.25rem 1.85rem !important;
    margin: 0.2rem 0 0.35rem !important;
    text-align: left !important;
    font-family: "KaTeX_Math", "Cambria Math", "Latin Modern Math", serif, monospace;
    font-size: 0.85rem !important;
    color: #ffffff;
    overflow-x: auto !important;
    max-width: 100%;
}

.math-display>.katex-display {
    padding: 0 !important;
    margin: 0 !important;
    text-align: left !important;
}

.math-inline {
    font-family: "KaTeX_Math", "Cambria Math", "Latin Modern Math", serif, monospace;
    color: #ffffff;
    font-size: 0.85em;
}

.katex {
    font-size: 0.85em !important;
    color: inherit;
}

.katex-display .katex {
    font-size: 0.85em !important;
    text-align: left !important;
}

.code-block {
    background: #060a12;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 0.85rem 1.1rem;
    margin: 0.85rem 0;
    overflow-x: auto;
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    color: #e0e0e0;
}

.reasoning-content code {
    font-family: var(--font-mono, monospace);
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    padding: 2px 5px;
    color: #81c784;
}

/* Outbound Customer Message Preview */

.customer-message-card {
    background: rgba(33, 150, 243, 0.05);
    border: 1px solid rgba(33, 150, 243, 0.25);
    border-left: 4px solid var(--primary);
    border-radius: 6px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.customer-message-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.customer-message-body {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text);
}

.error {
    color: var(--danger);
}

.validation {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: -6px;
}

.validation:empty {
    display: none;
}

/* Spinner */

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* Footer */

footer {
    border-top: 1px solid var(--border);
    padding: 1rem 0;
    text-align: center;
    color: var(--text-faint);
    font-size: 0.8125rem;
}

/* Responsive */

@media (max-width: 720px) {
    .hero .container {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.1rem;
    }

    .hero .subtitle {
        white-space: normal;
    }

    .hero .subtitle::before {
        content: none;
    }

    .grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .card-half,
    .card-wide {
        grid-column: 1 / -1;
    }
}