/* Beacon — Mobile-first chat UI */
/* iOS-optimized, dark theme, purpose-built feel */

:root {
    --bg-primary: #0A1628;
    --bg-secondary: #111D31;
    --bg-tertiary: #1A2740;
    --surface: #1E2D45;
    --surface-hover: #253550;
    --accent: #4F9CF7;
    --accent-dim: rgba(79, 156, 247, 0.15);
    --accent-glow: rgba(79, 156, 247, 0.3);
    --text-primary: #F0F4F8;
    --text-secondary: #8899AA;
    --text-muted: #5A6B7D;
    --user-bubble: #4F9CF7;
    --user-text: #FFFFFF;
    --border: rgba(255, 255, 255, 0.06);
    --shadow: rgba(0, 0, 0, 0.3);
    --success: #34D399;
    --warning: #FBBF24;
    --error: #F87171;
    --radius: 16px;
    --radius-sm: 10px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh; /* dynamic viewport height for mobile */
    max-width: 600px;
    margin: 0 auto;
}

#app.hidden {
    display: none;
}

/* Landing page */
#landing {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at top, var(--accent-dim) 0%, transparent 60%),
        radial-gradient(ellipse at bottom, rgba(79, 156, 247, 0.08) 0%, transparent 50%);
}

#landing.hidden {
    display: none;
}

.landing-content {
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.landing-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 0 40px var(--accent-glow);
}

.landing-title {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.8px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.landing-subtitle {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 28px;
}

.landing-description {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 36px;
}

.landing-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
}

.access-label {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.access-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.access-input::placeholder {
    color: var(--text-muted);
}

.access-submit {
    padding: 14px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.access-submit:hover {
    background: #3D8AE5;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.access-submit:active {
    transform: translateY(0);
}

.access-submit:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.access-error {
    font-size: 13px;
    color: var(--error);
    min-height: 18px;
    text-align: center;
    animation: fadeIn 0.2s ease;
}

.landing-footnote {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.landing-disclaimer {
    font-size: 10px;
    line-height: 1.5;
    color: var(--text-muted);
    letter-spacing: 0.2px;
    margin-top: 8px;
    padding: 0 4px;
    text-align: center;
}

/* Header */
#header {
    flex-shrink: 0;
    padding: calc(var(--safe-top) + 8px) 16px 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.beacon-logo {
    display: flex;
    align-items: center;
}

.header-title h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-btn {
    background: var(--surface);
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover {
    background: var(--surface-hover);
    color: var(--accent);
}

/* Chat container */
#chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

#messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100%;
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: fadeIn 0.3s ease;
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: var(--surface);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-bubble p {
    margin: 0 0 8px 0;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble strong {
    font-weight: 600;
    color: var(--accent);
}

/* Tables in responses */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.message-bubble th,
.message-bubble td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.message-bubble th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-bubble td {
    color: var(--text-primary);
}

/* Code blocks in responses */
.message-bubble pre {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.message-bubble code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    background: var(--bg-primary);
    padding: 2px 5px;
    border-radius: 4px;
}

.message-bubble pre code {
    background: none;
    padding: 0;
}

/* Lists */
.message-bubble ul, .message-bubble ol {
    padding-left: 20px;
    margin: 6px 0;
}

.message-bubble li {
    margin: 3px 0;
}

/* Status indicator */
.status-bubble {
    background: transparent !important;
    padding: 8px 0 !important;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    animation: fadeIn 0.3s ease;
}

.status-spinner {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 2px solid var(--accent-dim);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.status-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: opacity 0.2s;
}

/* Quick actions */
#quick-actions {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
}

#quick-actions.hidden {
    display: none;
}

.quick-action {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-action:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* Input area */
#input-area {
    flex-shrink: 0;
    padding: 8px 16px calc(var(--safe-bottom) + 8px);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--surface);
    border-radius: 24px;
    padding: 6px 6px 6px 16px;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.input-container:focus-within {
    border-color: var(--accent);
}

#message-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    outline: none;
    max-height: 120px;
    padding: 6px 0;
}

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

.send-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.4;
}

.send-btn:not(:disabled) {
    opacity: 1;
}

.send-btn:not(:disabled):hover {
    background: #3D8AE5;
    transform: scale(1.05);
}

.send-btn:disabled {
    cursor: default;
}

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

/* Scrollbar */
#chat-container::-webkit-scrollbar {
    width: 4px;
}

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

#chat-container::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

/* Desktop adjustments */
@media (min-width: 601px) {
    #app {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}

/* Response card styles */
.response-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin: 8px 0;
}

.response-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.response-card-header .icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
}

/* Metric highlights */
.metric {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

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

.metric-change.positive {
    color: var(--success);
}

.metric-change.negative {
    color: var(--error);
}

/* Tool activity indicator */
.tool-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 0;
    font-style: italic;
}

.tool-indicator .dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}
