/* ══════════════════════════════════════════════════════════════════
   Echo — Spotify DJ Agent · Premium Dark Theme
   ══════════════════════════════════════════════════════════════════ */

:root {
    /* Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a26;
    --bg-surface: #1e1e2e;
    --bg-hover: #252536;

    --text-primary: #e8e8f0;
    --text-secondary: #9d9db8;
    --text-muted: #6b6b85;

    --spotify-green: #1DB954;
    --spotify-green-hover: #1ed760;
    --accent-gradient: linear-gradient(135deg, #1DB954, #1ed760);
    --accent-glow: 0 0 20px rgba(29, 185, 84, 0.3);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(29, 185, 84, 0.2);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── App Layout ──────────────────────────────────────────────────── */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
}

/* ── Header ──────────────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(20px);
    background: rgba(10, 10, 15, 0.8);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: rgba(29, 185, 84, 0.1);
    border: 1px solid rgba(29, 185, 84, 0.2);
}

.header-text h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* link variant of btn-icon (logout) */
a.btn-icon {
    text-decoration: none;
}

.user-name {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.now-playing {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 200px;
    overflow: hidden;
}

.now-playing-dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--spotify-green);
    animation: pulse 2s ease-in-out infinite;
}

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

#now-playing-text {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.chat-container::-webkit-scrollbar {
    width: 6px;
}
.chat-container::-webkit-scrollbar-track {
    background: transparent;
}
.chat-container::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

/* ── Welcome Screen ──────────────────────────────────────────────── */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    animation: fadeIn 0.6s ease;
}

.welcome-icon {
    font-size: 56px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-screen h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.welcome-screen p {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 400px;
    line-height: 1.5;
    margin-bottom: 32px;
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 460px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-family);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-normal);
}

.quick-action:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: var(--accent-glow);
}

.qa-icon {
    font-size: 18px;
    flex-shrink: 0;
}

/* ── Messages ────────────────────────────────────────────────────── */
.messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    animation: messageIn 0.35s var(--transition-smooth);
    max-width: 100%;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.message.assistant .message-avatar {
    background: rgba(29, 185, 84, 0.15);
    border: 1px solid rgba(29, 185, 84, 0.25);
    color: var(--spotify-green);
}

.message.user .message-avatar {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.message-content {
    max-width: 75%;
    min-width: 0;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.assistant .message-bubble {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-top-left-radius: 4px;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #1a3a2a, #162a22);
    border: 1px solid rgba(29, 185, 84, 0.15);
    border-top-right-radius: 4px;
}

/* Tool call indicator */
.tool-calls {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tool-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(29, 185, 84, 0.08);
    border: 1px solid rgba(29, 185, 84, 0.15);
    border-radius: 20px;
    font-size: 11px;
    color: var(--spotify-green);
    font-weight: 500;
}

.tool-badge::before {
    content: "⚡";
    font-size: 10px;
}

/* Guardrail badge */
.guardrail-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 20px;
    font-size: 11px;
    color: #ef4444;
    font-weight: 500;
}

/* ── Confirmation UI ─────────────────────────────────────────────── */
.confirmation-bubble {
    border-color: rgba(251, 191, 36, 0.25) !important;
    background: linear-gradient(135deg, #1e1e2e, #1a1a26) !important;
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.08);
}

.confirmation-buttons {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}

.btn-approve,
.btn-deny {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-approve {
    background: rgba(29, 185, 84, 0.15);
    border: 1px solid rgba(29, 185, 84, 0.3);
    color: var(--spotify-green);
}

.btn-approve:hover {
    background: rgba(29, 185, 84, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(29, 185, 84, 0.2);
}

.btn-deny {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #ef4444;
}

.btn-deny:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

/* Pending approval badge */
.tool-badge.pending-approval {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.tool-badge.pending-approval::before {
    content: "";
}

/* Policy approved badge */
.tool-badge.policy-approved {
    background: rgba(29, 185, 84, 0.1);
    border-color: rgba(29, 185, 84, 0.2);
    color: var(--spotify-green);
}

.tool-badge.policy-approved::before {
    content: "";
}

/* ── Typing Indicator ────────────────────────────────────────────── */
.typing-indicator {
    display: flex;
    gap: 12px;
    animation: messageIn 0.35s ease;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    border-top-left-radius: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--spotify-green);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Input ────────────────────────────────────────────────────────── */
.input-container {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border-subtle);
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(20px);
}

.input-form {
    display: flex;
    width: 100%;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 4px 4px 4px 16px;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.input-wrapper:focus-within {
    border-color: var(--spotify-green);
    box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.1);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.5;
    padding: 10px 0;
    resize: none;
    max-height: 120px;
}

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

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--spotify-green);
    color: #000;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.btn-send:hover:not(:disabled) {
    background: var(--spotify-green-hover);
    transform: scale(1.05);
}

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

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .app-container {
        max-width: 100%;
    }

    .header {
        padding: 12px 16px;
    }

    .chat-container {
        padding: 16px;
    }

    .input-container {
        padding: 12px 16px 20px;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .message-content {
        max-width: 85%;
    }

    .welcome-screen h2 {
        font-size: 24px;
    }
}
