/* ═══════════════════════════════════════════
   Mamba 370M — Debug/Demo UI Styles
   ═══════════════════════════════════════════ */

:root {
    --bg-primary: #0f0f17;
    --bg-secondary: #16162a;
    --bg-card: #1c1c38;
    --bg-input: #22223e;
    --bg-hover: #2a2a4a;
    --text-primary: #e8e8f0;
    --text-secondary: #9a9ab8;
    --text-muted: #6a6a88;
    --accent: #7c5cff;
    --accent-glow: rgba(124, 92, 255, 0.25);
    --accent-hover: #9078ff;
    --green: #3ecf8e;
    --green-bg: rgba(62, 207, 142, 0.12);
    --red: #f04e4e;
    --red-bg: rgba(240, 78, 78, 0.12);
    --yellow: #f0c040;
    --yellow-bg: rgba(240, 192, 64, 0.12);
    --blue: #4ea8f0;
    --blue-bg: rgba(78, 168, 240, 0.12);
    --border: #2c2c4a;
    --radius: 12px;
    --radius-sm: 8px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
}

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

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ── */
.app-layout {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.chat-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
    padding: 0 16px;
}

/* ── Session Header ── */
.session-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.session-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    font-weight: 600;
}

.session-id {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 2px 8px;
    border-radius: 4px;
}

.header-divider {
    width: 1px;
    height: 36px;
    background: var(--border);
}

.app-title {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #ff6eb4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex: 1;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-reset {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-reset:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.btn-logout {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-logout:hover {
    color: var(--red);
    border-color: var(--red);
}

.btn-send {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent), #6040e0);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-hover), #7050f0);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent), #6040e0);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-login:hover {
    box-shadow: 0 0 30px var(--accent-glow);
    transform: translateY(-1px);
}

/* ── Metrics ── */
.metrics-panel {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.metric-sub {
    font-size: 11px;
    color: var(--text-secondary);
}

.metric-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.metric-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 2px;
    transition: width 0.5s ease;
}

.metric-bar-fill.bar-danger {
    background: linear-gradient(90deg, var(--yellow), var(--red));
}

.status-indicator {
    font-weight: 600;
}

.status-up {
    color: var(--green);
}

.status-down {
    color: var(--red);
}

/* ── Chat Container ── */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-message {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-user {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.msg-assistant {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.06), rgba(255, 110, 180, 0.04));
    border: 1px solid rgba(124, 92, 255, 0.15);
}

.msg-avatar {
    font-size: 24px;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-content {
    flex: 1;
    min-width: 0;
}

.msg-role {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.msg-text {
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}

.msg-text.streaming {
    color: var(--accent);
}

.msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    font-family: var(--font-mono);
}

.cursor {
    animation: blink 0.8s infinite;
    color: var(--accent);
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.typing-dots span {
    animation: dotPulse 1.4s infinite both;
    font-size: 18px;
    color: var(--accent);
    margin-right: 4px;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

/* ── Input Area ── */
.chat-input-area {
    padding: 12px 0 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.toggle-text {
    font-weight: 500;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-textarea {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    resize: none;
    outline: none;
    transition: border-color var(--transition);
}

.chat-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-textarea::placeholder {
    color: var(--text-muted);
}

.chat-textarea:disabled {
    opacity: 0.5;
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    font-family: var(--font-mono);
}

.input-hint .warning {
    color: var(--yellow);
    font-weight: 500;
}

/* ── Status Messages ── */
.status-message {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 8px;
}

.status-info {
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid rgba(78, 168, 240, 0.2);
}

.status-warn {
    background: var(--yellow-bg);
    color: var(--yellow);
    border: 1px solid rgba(240, 192, 64, 0.2);
}

.status-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(240, 78, 78, 0.2);
}

/* ── Spinner ── */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ── Login ── */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(ellipse at 50% 0%, rgba(124, 92, 255, 0.12) 0%, transparent 60%),
                var(--bg-primary);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #ff6eb4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.login-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(240, 78, 78, 0.2);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 20px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .session-header {
        flex-wrap: wrap;
    }

    .app-title {
        font-size: 20px;
    }
}
