/* base.css — reset, variables, typography, ambient gradients */

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

:root {
    --void: #06070d;
    --deep: #0e1018;
    --surface: #161a24;
    --cyan: #00c8ff;
    --violet: #7850ff;
    --mint: #00ffb4;
    --warning: #ffaa30;
    --error: #ff4466;
    --portable: #9b7aff;  /* Lighter violet — portable mode identity, not a warning */
    --text: #e0e8f0;
    --text-muted: #6a7a8a;
    --text-dim: #3a4a5a;
    --border: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(0, 200, 255, 0.25);
    --bg-user: rgba(0, 200, 255, 0.04);
    --bg-assistant: rgba(255, 255, 255, 0.02);
    --bg-source: rgba(0, 255, 180, 0.08);
}

body {
    background: var(--void);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    /* iPad/iOS Safari: 100vh is the LARGE viewport (ignores the dynamic toolbars), so with
       overflow:hidden the bottom composer + its buttons get pushed off-screen with no way to
       scroll to them. 100dvh tracks the VISIBLE viewport, keeping the column flex (header →
       scrollable #messages → #input-area) inside the screen. vh first = fallback for browsers
       without dvh; on desktop the two are identical (no regression). */
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ambient background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(0, 180, 255, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(120, 80, 255, 0.02) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 90%, rgba(0, 255, 180, 0.015) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* === HEADER === */
#header {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--deep);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 1;
    position: relative;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Mini orbital mark */
.orbital {
    width: 32px;
    height: 32px;
    position: relative;
}

.orbital .ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1.2px solid transparent;
}

.orbital .ring:nth-child(1) {
    border-top-color: rgba(0, 200, 255, 0.7);
    border-right-color: rgba(0, 200, 255, 0.12);
    animation: orbit 12s linear infinite;
}

.orbital .ring:nth-child(2) {
    inset: 5px;
    border-bottom-color: rgba(120, 80, 255, 0.6);
    border-left-color: rgba(120, 80, 255, 0.1);
    animation: orbit 8s linear infinite reverse;
}

.orbital .ring:nth-child(3) {
    inset: 10px;
    border-top-color: rgba(0, 255, 180, 0.5);
    border-right-color: rgba(0, 255, 180, 0.08);
    animation: orbit 16s linear infinite;
}

.orbital .core {
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 200, 255, 0.3) 0%, transparent 70%);
}

@keyframes orbit {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.header-title {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 300;
    letter-spacing: 8px;
    background: linear-gradient(90deg, #00c8ff 0%, #7850ff 50%, #00ffb4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.5px;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover {
    color: var(--cyan);
    border-color: rgba(0, 200, 255, 0.2);
    background: rgba(0, 200, 255, 0.05);
}

#status-indicator {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

#status-indicator.online { color: var(--mint); }
#status-indicator.offline { color: var(--error); }
#status-indicator.connecting { color: var(--warning); }

/* === VIEW CONTAINERS === */
#chat-view,
#dashboard-view,
#audit-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;   /* Allow flex children to shrink below content size */
}

/* === MESSAGES === */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    z-index: 1;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.06) transparent;
}

#messages::-webkit-scrollbar { width: 5px; }
#messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 3px; }

/* === INPUT === */
#input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--deep);
    z-index: 1;
    position: relative;
}

#input-form {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
}

#message-input {
    flex: 1;
    background: var(--void);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s;
}

#message-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 1px rgba(0, 200, 255, 0.08);
}

#message-input::placeholder {
    color: var(--text-dim);
}

#send-btn {
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.15) 0%, rgba(120, 80, 255, 0.15) 100%);
    color: var(--cyan);
    border: 1px solid rgba(0, 200, 255, 0.2);
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

#send-btn:hover {
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.25) 0%, rgba(120, 80, 255, 0.25) 100%);
    border-color: rgba(0, 200, 255, 0.4);
    box-shadow: 0 0 20px rgba(0, 200, 255, 0.1);
}

#send-btn:disabled {
    background: var(--surface);
    color: var(--text-dim);
    border-color: var(--border);
    cursor: not-allowed;
    box-shadow: none;
}

/* === WELCOME === */
.welcome-msg .content {
    color: var(--text-muted);
}

.typing {
    color: var(--text-muted);
    font-style: italic;
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Orbital pulse during thinking/streaming */
.orbital.thinking .core {
    animation: orbital-pulse 2s ease-in-out infinite;
}

@keyframes orbital-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; box-shadow: 0 0 12px rgba(0, 200, 255, 0.4); }
}

@media (prefers-reduced-motion: reduce) {
    .orbital .ring { animation: none; }
}
