/* --- HIGH-END TECH AESTHETIC --- */
:root {
    --bg-color: #030303;
    --accent-cyan: #00f2ff;
    --accent-purple: #bd00ff;
    --accent-error: #ff0055;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-dim: rgba(255, 255, 255, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --panel-bg: rgba(10, 10, 10, 0.6);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
}

/* --- UI LAYER --- */
#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; /* Allows click-through to 3D scene */
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 30px;
}

/* --- HEADER --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.brand {
    font-family: 'Dancing Script', cursive;
    font-size: 2.2rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
}

/* Remove dot and previous gradient styles */
.brand::before { display: none; }
.brand-gradient { display: none; }

.version {
    font-size: 0.6rem;
    color: var(--accent-cyan);
    font-weight: 400;
    margin-left: 10px;
    background: rgba(0, 242, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.status-panel {
    text-align: right;
}

.status-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 5px;
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background-color: #333;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.status-dot.healthy {
    background-color: #00ff88;
    box-shadow: 0 0 8px #00ff88;
}

.status-dot.busy {
    background-color: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
    animation: blink 0.5s infinite alternate;
}

.status-text {
    font-family: 'Courier Prime', monospace;
    font-size: 0.65rem;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.track-info {
    font-family: 'Courier Prime', monospace;
    font-size: 0.75rem;
    color: var(--accent-cyan);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 0 5px rgba(0, 242, 255, 0.3);
}

/* --- TECH-CLOUD DIALOGUE (Top-Right of Sphere) --- */
.active-message-zone {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 420px;
    /* Offset significantly to the top-right to ensure center is clear */
    transform: translate(220px, -300px);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
    z-index: 25;
}

.active-bubble {
    padding: 22px 28px;
    /* Organic 'Cloud' Shape: soft and techy */
    border-radius: 40px 40px 40px 15px; 
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 0 20px rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    animation: cloudEnter 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
    position: relative;
}

/* The 'Cloud' connection point / tail */
.active-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 20px;
    width: 20px;
    height: 20px;
    background: inherit;
    backdrop-filter: inherit;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
    z-index: -1;
}

.active-bubble.assistant {
    border-color: rgba(0, 242, 255, 0.2);
    background: radial-gradient(circle at top left, rgba(0, 242, 255, 0.05), rgba(255, 255, 255, 0.02));
    box-shadow: 0 10px 40px rgba(0, 242, 255, 0.08);
}

.active-bubble .content {
    font-size: 1rem;
    line-height: 1.5;
    text-align: left;
    color: var(--text-primary);
    font-weight: 300;
    letter-spacing: 0.3px;
}

@keyframes cloudEnter {
    from { opacity: 0; transform: scale(0.8) translateY(20px); filter: blur(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

@keyframes cloudExit {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.9) translateY(-10px); filter: blur(5px); }
}

/* Clean up previous styles */
.active-bubble.user { border-left: none; }
@keyframes ghostEnter { from { opacity: 0; } to { opacity: 1; } }
@keyframes ghostExit { from { opacity: 1; } to { opacity: 0; } }

/* Remove old animations */
@keyframes bubbleEnter { from { opacity: 0; } to { opacity: 1; } }
@keyframes bubbleExit { from { opacity: 1; } to { opacity: 0; } }

@keyframes bubbleExit {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-10px) scale(0.98); }
}


/* --- BOTTOM BAR (Footer) --- */
.footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 20px;
    pointer-events: none;
}

/* Left: Text Input */
.footer-left {
    pointer-events: auto;
}

.input-group {
    display: flex;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 5px;
    backdrop-filter: blur(5px);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-group:focus-within {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.1);
}

#text-input {
    background: transparent;
    border: none;
    color: white;
    padding: 10px 15px;
    width: 100%;
    font-family: 'Inter', sans-serif;
    outline: none;
    font-size: 0.9rem;
}

#send-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--accent-cyan);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-btn:hover {
    background: var(--accent-cyan);
    color: #000;
}

/* Center: Record Button */
.footer-center {
    display: flex;
    justify-content: center;
    pointer-events: auto;
}

.main-ctrl-btn {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    outline: none;
}

.main-ctrl-btn:hover, .main-ctrl-btn.active {
    border-color: var(--accent-cyan);
    background: rgba(0, 242, 255, 0.05);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.2);
    width: 90px;
    height: 90px;
}

.main-ctrl-btn.active .mic-icon {
    color: var(--accent-cyan);
    text-shadow: 0 0 10px var(--accent-cyan);
}

.main-ctrl-btn.recording {
    border-color: var(--accent-error);
    background: rgba(255, 0, 85, 0.1);
    box-shadow: 0 0 30px rgba(255, 0, 85, 0.3);
    animation: pulse 1.5s infinite;
}

.mic-icon {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.3s;
}

.main-ctrl-btn.recording .mic-icon {
    color: var(--accent-error);
}

.btn-label {
    position: absolute;
    bottom: -25px;
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    white-space: nowrap;
}

/* Right: Frequency Monitor */
.footer-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
}

.monitor-label {
    font-family: 'Courier Prime', monospace;
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-bottom: 5px;
    letter-spacing: 1px;
}

#mini-monitor {
    border-bottom: 1px solid var(--accent-cyan);
    border-left: 1px solid var(--glass-border);
    background: linear-gradient(to top, rgba(0, 242, 255, 0.05), transparent);
}

/* 3D Canvas */
#canvas-container {
    position: absolute;
    top: 0; left: 0;
    z-index: 1;
}

/* Animations */
@keyframes blink {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 85, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(255, 0, 85, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 0, 85, 0); }
}

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

/* Responsive */
@media (max-width: 768px) {
    .chat-panel {
        left: 0; bottom: 0; top: auto;
        width: 100%; height: 40%;
        border-radius: 12px 12px 0 0;
        background: rgba(10, 10, 10, 0.9);
    }
    .footer {
        position: absolute;
        bottom: 20px;
        width: 100%;
        padding: 0 20px;
        z-index: 20;
    }
}