/* ============================================
   Nova Encarnação - Avatar Interativo
   Design System & Styles
   ============================================ */

/* CSS Variables */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-glass: rgba(18, 18, 26, 0.85);
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
}

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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Canvas Container */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#canvas-container canvas {
    display: block;
}

/* UI Overlay */
#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

#ui-overlay>* {
    pointer-events: auto;
}

/* Status Bar */
#status-bar {
    display: flex;
    justify-content: center;
    padding: 10px;
}

#connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--success);
    animation: none;
}

.status-dot.error {
    background: var(--error);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Chat Container */
#chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    max-height: 40vh;
    overflow: hidden;
    padding: 20px 0;
    pointer-events: none;
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 0 20px;
    scrollbar-width: none;
}

#chat-messages::-webkit-scrollbar {
    display: none;
}

.chat-message {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 18px;
    backdrop-filter: blur(12px);
    animation: slideIn 0.3s ease;
}

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

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Voice Controls */
#voice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-bottom: 20px;
}

#transcription {
    min-height: 24px;
    padding: 12px 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 80%;
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-normal);
}

#transcription.visible {
    opacity: 1;
    transform: translateY(0);
}

#mic-button {
    position: relative;
    width: 72px;
    height: 72px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 20px var(--accent-glow);
}

#mic-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px var(--accent-glow);
}

#mic-button:active {
    transform: scale(0.95);
}

#mic-button.listening {
    background: linear-gradient(135deg, var(--success), #16a34a);
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4);
}

#mic-button.processing {
    background: linear-gradient(135deg, var(--warning), #d97706);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
}

#mic-button.error {
    background: linear-gradient(135deg, var(--error), #dc2626);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

#mic-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    opacity: 0;
    z-index: -1;
}

#mic-button.listening #mic-pulse {
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

#mic-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: opacity var(--transition-normal);
}

/* Text Input */
#text-input-container {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 500px;
    margin-bottom: 16px;
}

#text-input {
    flex: 1;
    padding: 12px 18px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-normal);
}

#text-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

#send-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 24px;
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

#send-button:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 20px var(--accent-glow);
}

#send-button:active {
    transform: scale(0.98);
}

#send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity var(--transition-slow);
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    #ui-overlay {
        padding: 16px;
    }

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

    #mic-button {
        width: 64px;
        height: 64px;
    }
}

/* Animations for avatar speaking */
.avatar-speaking #mic-hint {
    opacity: 0;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}