/* ============================================
   VoAIce — Premium Dark Theme Stylesheet
   ============================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a28;
    --bg-hover: #22223a;

    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #5a5a78;

    --accent-primary: #6c5ce7;
    --accent-glow: rgba(108, 92, 231, 0.35);
    --accent-light: #a29bfe;

    --success: #00d2d3;
    --success-glow: rgba(0, 210, 211, 0.3);
    --warning: #ffa502;
    --danger: #ff4757;

    --border: rgba(255, 255, 255, 0.06);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px var(--accent-glow);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::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;
}

/* --- Layout --- */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

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

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

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    transition: var(--transition);
}

.status-badge.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
}

.status-badge.connected {
    color: var(--success);
    border-color: rgba(0, 210, 211, 0.2);
}

/* --- Main Content --- */
.main {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* --- Conversation Area --- */
.conversation {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.conversation::-webkit-scrollbar {
    width: 4px;
}

.conversation::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    gap: 12px;
    opacity: 0.7;
    transition: var(--transition);
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.welcome-message h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Message bubbles */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
    animation: messageIn 0.3s ease;
    word-wrap: break-word;
}

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

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent-primary), #5a4bd1);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    opacity: 0.6;
}

/* --- State Indicator --- */
.state-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px 0 8px;
}

.state-visual {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb {
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb-core {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    transition: var(--transition);
    z-index: 2;
}

.orb-ring {
    position: absolute;
    border-radius: 50%;
    border: 1.5px solid var(--accent-primary);
    opacity: 0;
    transition: var(--transition);
}

.orb-ring-1 {
    width: 36px;
    height: 36px;
}

.orb-ring-2 {
    width: 52px;
    height: 52px;
}

.orb-ring-3 {
    width: 68px;
    height: 68px;
}

/* Listening state — pulsing rings */
.state-listening .orb-core {
    background: var(--success);
    box-shadow: 0 0 20px var(--success-glow);
}

.state-listening .orb-ring {
    border-color: var(--success);
    animation: orbPulse 2s ease-in-out infinite;
}

.state-listening .orb-ring-1 {
    animation-delay: 0s;
}

.state-listening .orb-ring-2 {
    animation-delay: 0.4s;
}

.state-listening .orb-ring-3 {
    animation-delay: 0.8s;
}

@keyframes orbPulse {
    0%, 100% {
        opacity: 0;
        transform: scale(0.6);
    }
    50% {
        opacity: 0.5;
        transform: scale(1);
    }
}

/* Processing state — spinning */
.state-processing .orb-core {
    background: var(--warning);
    box-shadow: 0 0 20px rgba(255, 165, 2, 0.3);
    animation: corePulse 1s ease-in-out infinite;
}

.state-processing .orb-ring {
    border-color: var(--warning);
    opacity: 0.4;
    animation: orbSpin 3s linear infinite;
}

.state-processing .orb-ring-1 {
    border-style: dashed;
    animation-duration: 2s;
}

.state-processing .orb-ring-2 {
    border-style: dotted;
    animation-duration: 3s;
    animation-direction: reverse;
}

.state-processing .orb-ring-3 {
    border-style: dashed;
    animation-duration: 4s;
}

@keyframes corePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.8); }
}

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

/* Speaking state — waveform-like animation */
.state-speaking .orb-core {
    background: var(--accent-primary);
    box-shadow: 0 0 24px var(--accent-glow);
    animation: speakingPulse 0.6s ease-in-out infinite alternate;
}

.state-speaking .orb-ring {
    border-color: var(--accent-light);
    animation: orbWave 1.5s ease-in-out infinite;
}

.state-speaking .orb-ring-1 {
    animation-delay: 0s;
}

.state-speaking .orb-ring-2 {
    animation-delay: 0.2s;
}

.state-speaking .orb-ring-3 {
    animation-delay: 0.4s;
}

@keyframes speakingPulse {
    from {
        transform: scale(1);
        box-shadow: 0 0 20px var(--accent-glow);
    }
    to {
        transform: scale(1.15);
        box-shadow: 0 0 35px var(--accent-glow);
    }
}

@keyframes orbWave {
    0%, 100% {
        opacity: 0.1;
        transform: scale(0.85);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

.state-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: var(--transition);
}

/* --- Controls --- */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 24px 32px;
}

.mic-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent-primary), #5a4bd1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-glow);
    position: relative;
    overflow: hidden;
}

.mic-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: var(--transition);
}

.mic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 50px var(--accent-glow);
}

.mic-btn:hover::before {
    opacity: 1;
}

.mic-btn:active {
    transform: scale(0.95);
}

.mic-btn.active {
    background: linear-gradient(135deg, var(--danger), #e84118);
    box-shadow: 0 0 40px rgba(255, 71, 87, 0.4);
}

.mic-btn svg {
    width: 24px;
    height: 24px;
}

.hidden {
    display: none !important;
}

.reset-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.reset-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.12);
}

.reset-btn svg {
    width: 18px;
    height: 18px;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .header {
        padding: 12px 16px;
    }

    .conversation {
        padding: 16px;
    }

    .controls {
        padding: 12px 16px 24px;
    }

    .mic-btn {
        width: 56px;
        height: 56px;
    }
}

/* --- Utility --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
