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

:root {
    --bg-primary: #0a0a12;
    --bg-card: rgba(18, 18, 30, 0.85);
    --bg-card-border: rgba(255, 255, 255, 0.06);
    --bg-transcript: rgba(255, 255, 255, 0.03);
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-dim: #55556a;
    --accent: #6c5ce7;
    --accent-glow: rgba(108, 92, 231, 0.35);
    --accent-light: #a29bfe;
    --green: #00d26a;
    --green-glow: rgba(0, 210, 106, 0.25);
    --red: #ff4757;
    --red-glow: rgba(255, 71, 87, 0.25);
    --user-bubble: rgba(108, 92, 231, 0.15);
    --user-bubble-border: rgba(108, 92, 231, 0.3);
    --bot-bubble: rgba(255, 255, 255, 0.05);
    --bot-bubble-border: rgba(255, 255, 255, 0.08);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ===== Background Orbs ===== */
.app-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

.bg-orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    top: -15%;
    left: -10%;
    animation: float1 18s ease-in-out infinite;
}

.bg-orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #00cec9 0%, transparent 70%);
    bottom: -10%;
    right: -8%;
    animation: float2 22s ease-in-out infinite;
}

.bg-orb-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #fd79a8 0%, transparent 70%);
    top: 50%;
    left: 60%;
    animation: float3 15s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(60px, 40px) scale(1.1); }
    66% { transform: translate(-30px, 80px) scale(0.95); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-50px, -30px) scale(1.05); }
    66% { transform: translate(40px, -60px) scale(0.9); }
}

@keyframes float3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-80px, 40px) scale(1.15); }
}

/* ===== Voice Card ===== */
.voice-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.04),
        0 20px 60px rgba(0,0,0,0.5),
        0 0 120px var(--accent-glow);
}

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

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

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #a29bfe);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.brand-sub {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 1px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.status-badge.connected {
    background: var(--green-glow);
    border-color: rgba(0, 210, 106, 0.3);
    color: var(--green);
}

.status-badge.connecting {
    background: rgba(253, 203, 110, 0.15);
    border-color: rgba(253, 203, 110, 0.3);
    color: #fdcb6e;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: background 0.3s ease;
}

.status-badge.connected .status-dot {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: pulse-dot 2s ease-in-out infinite;
}

.status-badge.connecting .status-dot {
    background: #fdcb6e;
    animation: pulse-dot 0.8s ease-in-out infinite;
}

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

/* ===== Voice Section ===== */
.voice-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 24px 30px;
}

.avatar-ring {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-inner {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(108,92,231,0.2), rgba(108,92,231,0.05));
    border: 2px solid rgba(108,92,231,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.4s ease;
    position: relative;
}

.avatar-ring.active .avatar-inner {
    border-color: var(--green);
    background: linear-gradient(145deg, rgba(0,210,106,0.15), rgba(0,210,106,0.05));
    box-shadow: 0 0 30px var(--green-glow);
}

.avatar-ring.speaking .avatar-inner {
    border-color: var(--accent-light);
    background: linear-gradient(145deg, rgba(108,92,231,0.25), rgba(162,155,254,0.1));
    box-shadow: 0 0 40px var(--accent-glow);
}

.mic-icon {
    color: var(--accent-light);
    transition: opacity 0.3s ease;
}

.avatar-ring.active .mic-icon,
.avatar-ring.speaking .mic-icon {
    opacity: 0;
    position: absolute;
}

.wave-bars {
    display: none;
    gap: 4px;
    align-items: center;
    height: 40px;
}

.avatar-ring.active .wave-bars,
.avatar-ring.speaking .wave-bars {
    display: flex;
}

.wave-bars span {
    display: block;
    width: 5px;
    border-radius: 4px;
    background: var(--green);
    animation: wave 1.2s ease-in-out infinite;
}

.avatar-ring.speaking .wave-bars span {
    background: var(--accent-light);
    animation-duration: 0.6s;
}

.wave-bars span:nth-child(1) { height: 12px; animation-delay: 0s; }
.wave-bars span:nth-child(2) { height: 24px; animation-delay: 0.15s; }
.wave-bars span:nth-child(3) { height: 36px; animation-delay: 0.3s; }
.wave-bars span:nth-child(4) { height: 24px; animation-delay: 0.45s; }
.wave-bars span:nth-child(5) { height: 12px; animation-delay: 0.6s; }

@keyframes wave {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}

/* Pulse rings */
.pulse-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(108,92,231,0.1);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.pulse-ring-1 { width: 120px; height: 120px; }
.pulse-ring-2 { width: 145px; height: 145px; }
.pulse-ring-3 { width: 170px; height: 170px; }

.avatar-ring.active .pulse-ring,
.avatar-ring.speaking .pulse-ring {
    opacity: 1;
    animation: pulse-expand 2.5s ease-out infinite;
}

.avatar-ring.speaking .pulse-ring {
    border-color: rgba(108,92,231,0.2);
}

.pulse-ring-2 { animation-delay: 0.4s !important; }
.pulse-ring-3 { animation-delay: 0.8s !important; }

@keyframes pulse-expand {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.6; }
    100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; }
}

.voice-label {
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    transition: color 0.3s ease;
    min-height: 1.3em;
}

.voice-timer {
    margin-top: 6px;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
    min-height: 1.8em;
}

/* ===== Transcript Section ===== */
.transcript-section {
    margin: 0 16px;
    border-radius: var(--radius-md);
    background: var(--bg-transcript);
    border: 1px solid var(--bg-card-border);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), padding 0.5s ease;
}

.transcript-section.open {
    max-height: 280px;
    padding: 0;
}

.transcript-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--bg-card-border);
    position: sticky;
    top: 0;
    background: rgba(18, 18, 30, 0.95);
    backdrop-filter: blur(8px);
    z-index: 2;
}

.transcript-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.transcript-count {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.transcript-messages {
    padding: 12px 16px;
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.transcript-messages::-webkit-scrollbar {
    width: 4px;
}

.transcript-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

/* Message Bubbles */
.msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    line-height: 1.5;
    animation: msg-in 0.3s ease-out;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg.user {
    align-self: flex-end;
    background: var(--user-bubble);
    border: 1px solid var(--user-bubble-border);
    color: var(--accent-light);
    border-bottom-right-radius: 4px;
}

.msg.bot {
    align-self: flex-start;
    background: var(--bot-bubble);
    border: 1px solid var(--bot-bubble-border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.msg-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
    opacity: 0.6;
}

.msg.user .msg-label { color: var(--accent-light); }
.msg.bot .msg-label { color: var(--text-secondary); }

/* ===== Call Button ===== */
.action-section {
    padding: 20px 24px;
}

.call-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, var(--accent), #7c6cf0);
    color: white;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.call-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.call-button:active {
    transform: translateY(0);
}

.call-button.connected {
    background: linear-gradient(135deg, var(--red), #e84118);
    box-shadow: 0 4px 20px var(--red-glow);
}

.call-button.connected:hover {
    box-shadow: 0 8px 30px var(--red-glow);
}

.call-button.connecting {
    background: linear-gradient(135deg, #fdcb6e, #e17055);
    pointer-events: none;
    opacity: 0.85;
}

.call-icon {
    display: flex;
    align-items: center;
}

/* ===== Footer ===== */
.card-footer {
    text-align: center;
    padding: 14px 24px;
    border-top: 1px solid var(--bg-card-border);
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 0.03em;
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
    .app-container { padding: 0; }
    .voice-card {
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    .voice-section { flex: 1; justify-content: center; }
    .transcript-section.open { max-height: 200px; }
}
