/* CSS Variables & Theme Setup */
:root {
    --bg-gradient: radial-gradient(circle at 50% 50%, #131224 0%, #080811 100%);
    --card-bg: rgba(20, 20, 35, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --primary-color: #8b5cf6; /* Vibrant violet */
    --primary-glow: rgba(139, 92, 246, 0.4);
    --accent-color: #06b6d4; /* Vibrant cyan */
    --accent-glow: rgba(6, 182, 212, 0.4);
    --danger-color: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --success-color: #10b981;
    --success-glow: rgba(16, 185, 129, 0.4);
    --bubble-user: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    --bubble-bot: rgba(255, 255, 255, 0.06);
    --font-sans: 'Inter', sans-serif;
    --font-title: 'Outfit', sans-serif;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* App Layout */
.app-container {
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 10px 20px 10px;
    border-bottom: 1px solid var(--card-border);
}

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

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: pulseGlow 3s infinite ease-in-out;
}

.logo h1 {
    font-family: var(--font-title);
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: -0.5px;
}

.logo h1 span {
    color: var(--accent-color);
}

/* Status Badge */
.status-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    padding: 6px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.status-badge.recording {
    border-color: var(--danger-color);
    box-shadow: 0 0 10px var(--danger-glow);
}

.status-badge.thinking {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

.status-badge.speaking {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-glow);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
    display: inline-block;
}

.status-badge.recording .pulse-dot {
    background-color: var(--danger-color);
    animation: blink 1s infinite alternate;
}

.status-badge.thinking .pulse-dot {
    background-color: var(--accent-color);
    animation: blink 1s infinite alternate;
}

.status-badge.speaking .pulse-dot {
    background-color: var(--primary-color);
    animation: blink 1s infinite alternate;
}

/* Main Content Grid */
.app-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    height: calc(100% - 80px);
}

@media (max-width: 768px) {
    .app-main {
        grid-template-columns: 1fr;
        height: auto;
        overflow-y: auto;
    }
    .app-container {
        height: auto;
        min-height: 100vh;
    }
}

/* Glass Cards */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

/* Left Panel Section */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.config-card h2 {
    font-family: var(--font-title);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

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

.control-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.control-group select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.control-group select option {
    background: #11111f;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-secondary {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-secondary:hover {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 0 15px var(--danger-glow);
}

/* Mic Interaction Panel */
.mic-card {
    flex: 1;
    justify-content: space-between;
    align-items: center;
    min-height: 250px;
}

.visualizer-container {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.waveform-canvas {
    width: 100%;
    height: 100%;
}

.mic-button-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.mic-btn {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    border: none;
    color: white;
    font-size: 2.2rem;
    cursor: pointer;
    box-shadow: 0 8px 32px var(--primary-glow);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    -webkit-user-select: none;
}

.mic-btn:hover {
    transform: scale(1.05);
}

.mic-btn:active, .mic-btn.active {
    background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
    box-shadow: 0 0 40px var(--danger-glow);
    transform: scale(0.95);
}

.mic-instruction {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 10px;
}

/* Right Panel: Chat List */
.chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.chat-header h3 {
    font-family: var(--font-title);
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-right: 10px;
}

/* Custom Scrollbar for Chat Panel */
.chat-history::-webkit-scrollbar {
    width: 6px;
}

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

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Bubbles */
.chat-bubble {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.bot-bubble {
    align-self: flex-start;
}

.bubble-content {
    padding: 14px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.user-bubble .bubble-content {
    background: var(--bubble-user);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.25);
}

.bot-bubble .bubble-content {
    background: var(--bubble-bot);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--card-border);
}

.bubble-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    align-self: flex-end;
}

.bot-bubble .bubble-time {
    align-self: flex-start;
}

/* Animations */
@keyframes pulseGlow {
    0%, 100% {
        filter: drop-shadow(0 0 2px var(--primary-glow));
    }
    50% {
        filter: drop-shadow(0 0 10px var(--primary-color));
    }
}

@keyframes blink {
    from {
        opacity: 0.4;
    }
    to {
        opacity: 1;
    }
}

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