/* Sage Web Chat — Dark theme */
:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface-light: #1f3050;
    --text: #e0e0e0;
    --text-dim: #8892a4;
    --accent: #e9a84c;
    --accent-dim: #c8893a;
    --sage-bubble: #1f3050;
    --user-bubble: #2a4a6b;
    --border: #2a3a5c;
    --danger: #e74c3c;
    --success: #2ecc71;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

/* Toggle switch */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.toggle {
    position: relative;
    width: 40px;
    height: 22px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    background: var(--text);
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* Avatar container — hidden; Clippy floats bottom-right via clippyjs */
.avatar-container {
    display: none;
}

/* Clippy — scale 2x, anchored to bottom-right corner */
.clippy {
    transform: scale(2);
    transform-origin: bottom right;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Chat area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
    word-wrap: break-word;
}

.message.sage {
    align-self: flex-start;
    background: var(--sage-bubble);
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: var(--user-bubble);
    border-bottom-right-radius: 4px;
}

.message .sender {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.message.sage .sender {
    color: var(--accent);
}

/* Status indicator */
.status-bar {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
    padding: 4px;
}

/* Input area */
.input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
}

.input-area input:focus {
    border-color: var(--accent);
}

.input-area input::placeholder {
    color: var(--text-dim);
}

.btn {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: var(--bg);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn:hover { background: var(--accent-dim); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-mic {
    background: var(--surface-light);
    color: var(--text);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 1.2rem;
}

.btn-mic.recording {
    background: var(--danger);
    color: white;
    animation: pulse 1s ease-in-out infinite;
}

/* Nav link */
.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.85rem;
}
.nav-link:hover { color: var(--accent); }

/* ===== Refinement page ===== */

.refine-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.refine-container h1 {
    color: var(--accent);
    margin-bottom: 20px;
}

.refine-container h2 {
    font-size: 1rem;
    color: var(--text-dim);
    margin: 20px 0 8px;
}

.refine-container textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 80px;
    outline: none;
}

.refine-container textarea:focus {
    border-color: var(--accent);
}

.refine-container input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}

.refine-container input[type="text"]:focus {
    border-color: var(--accent);
}

.btn-row {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.slots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}

.slot {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
}

.slot h3 {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.slot audio {
    width: 100%;
    margin: 8px 0;
}

.slot .desc {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 8px;
    max-height: 60px;
    overflow: hidden;
}

.profile-list {
    margin-top: 16px;
}

.profile-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
}

.profile-item .name {
    font-weight: 600;
    min-width: 120px;
}

.profile-item .active-badge {
    font-size: 0.75rem;
    background: var(--accent);
    color: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
}

.profile-item .actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-dim);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-left: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
