/* ============================================
   ROBÔ AMIGÁVEL — DESIGN SYSTEM & STYLES
   ============================================ */

/* --- CSS Custom Properties (Themes) --- */
:root {
    --bg-primary: #0D0D1A;
    --bg-secondary: #1A1A2E;
    --text-primary: #EAEAEA;
    --text-muted: #8888AA;
    --accent: #1B3A6B;
    --accent-glow: rgba(27, 58, 107, 0.4);
    --face-bg: var(--accent);
    --eye-white: #FFFFFF;
    --eye-iris: #3B2F1E;
    --eye-pupil: #1A1208;
    --eye-shine: rgba(255, 255, 255, 0.85);
    --mouth-color: #FFFFFF;
    --eyelid-color: var(--accent);
    --modal-bg: rgba(13, 13, 26, 0.95);
    --card-bg: #16162A;
    --card-border: rgba(255, 255, 255, 0.08);
    --input-bg: #0D0D1A;
    --input-border: rgba(255, 255, 255, 0.12);
    --input-focus: var(--accent);
    --mic-active: #39FF14;
    --mic-inactive: #FF3B3B;
    --font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.35s ease;
    --transition-slow: 0.6s ease;
}

/* Color Themes */
[data-theme="rosa"] {
    --accent: #FF69B4;
    --accent-glow: rgba(255, 105, 180, 0.35);
    --face-bg: #FF69B4;
    --eyelid-color: #FF69B4;
}
[data-theme="verde-neon"] {
    --accent: #39FF14;
    --accent-glow: rgba(57, 255, 20, 0.3);
    --face-bg: #22CC10;
    --eyelid-color: #22CC10;
}
[data-theme="azul-escuro"] {
    --accent: #1B3A6B;
    --accent-glow: rgba(27, 58, 107, 0.4);
    --face-bg: #1B3A6B;
    --eyelid-color: #1B3A6B;
}
[data-theme="laranja"] {
    --accent: #FF6B35;
    --accent-glow: rgba(255, 107, 53, 0.35);
    --face-bg: #FF6B35;
    --eyelid-color: #FF6B35;
}
[data-theme="branco"] {
    --accent: #E8E8F0;
    --accent-glow: rgba(232, 232, 240, 0.3);
    --face-bg: #D8D8E8;
    --eyelid-color: #D8D8E8;
    --eye-iris: #5A4F3E;
}

/* --- 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);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-user-select: none;
    user-select: none;
}

/* ============================================
   MODAL — CONFIGURATION
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--modal-bg);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    width: 90%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 36px 32px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 60px var(--accent-glow);
    animation: modalSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from { transform: translateY(30px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.modal-icon {
    font-size: 40px;
    margin-bottom: 12px;
    animation: iconBounce 2s ease infinite;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.modal-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.modal-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Form Fields */
.field-group {
    margin-bottom: 20px;
}

.field-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.required { color: #FF3B3B; }
.optional { color: var(--text-muted); font-weight: 400; text-transform: none; font-size: 0.78rem; }

.field-group input[type="url"],
.field-group input[type="text"],
.field-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field-group input:focus,
.field-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-group input::placeholder {
    color: rgba(255,255,255,0.2);
}

/* Range slider */
.field-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.field-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.field-group input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

/* Color Buttons */
.color-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: transparent;
    border: 2px solid var(--input-border);
    border-radius: 14px;
    cursor: pointer;
    transition: border-color var(--transition-fast), transform var(--transition-fast), background var(--transition-fast);
    flex: 1;
    min-width: 70px;
}

.color-btn:hover {
    border-color: rgba(255,255,255,0.25);
    transform: translateY(-2px);
}

.color-btn.selected {
    border-color: var(--swatch);
    background: rgba(255,255,255,0.05);
    box-shadow: 0 0 12px rgba(255,255,255,0.05);
}

.swatch {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--swatch);
    border: 2px solid rgba(255,255,255,0.15);
}

.color-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Primary Button */
.btn-primary {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
    filter: brightness(1.15);
}

.btn-primary:active {
    transform: translateY(0);
}

[data-theme="branco"] .btn-primary {
    color: #1A1A2E;
}

/* ===== TOP CONTROLS (Settings & Kids Mode) ===== */
.top-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 500;
    display: flex;
    gap: 12px;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(15deg) scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.kids-btn {
    font-size: 24px;
    /* Reset rotation on hover since emoji shouldn't spin like the gear */
}

.kids-btn:hover {
    transform: scale(1.1);
}

.kids-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* Settings gear button */
.settings-btn {
    color: var(--text-muted);
}

.settings-btn:hover {
    color: var(--text-primary);
}

/* ============================================
   ROBOT FACE
   ============================================ */
.robot-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--bg-primary);
    transition: opacity var(--transition-slow);
    perspective: 1200px; /* Added for 3D head turn effect */
}

.robot-container.hidden {
    display: none;
}

#camera-feed,
#motion-canvas {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.robot-face-wrapper {
    width: 90vw;
    max-width: 850px;
    animation: faceAppear 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center;
    transform-style: preserve-3d;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes faceAppear {
    from { transform: scale(0.8); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* SVG Face */
#face-bg {
    fill: var(--face-bg);
    filter: drop-shadow(0 8px 40px var(--accent-glow));
    transition: fill var(--transition-normal);
}

/* Eyebrows */
.eyebrow {
    fill: none;
    stroke: var(--mouth-color);
    stroke-width: 10;
    stroke-linecap: round;
    transition: transform var(--transition-normal), opacity 0.2s, stroke 0.2s;
}

#robot-face.surprised .eyebrow {
    transform: translateY(-20px);
}

#robot-face.confused #left-eyebrow {
    transform: translateY(-10px) rotate(-10deg);
}
#robot-face.confused #right-eyebrow {
    transform: translateY(10px) rotate(-10deg);
}

#robot-face.happy .eyebrow {
    transform: translateY(-5px);
}


/* Blush Cheeks */
.blush-cheek {
    fill: #FF8DA1; /* Soft pink blush */
    opacity: 0.14; /* Very subtle and almost invisible by default */
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}
.blush-cheek.left {
    transform-origin: 200px 325px;
}
.blush-cheek.right {
    transform-origin: 600px 325px;
}

/* Blush dynamics for extra cuteness and expression */
#robot-face.happy .blush-cheek {
    opacity: 0.35;
    transform: scale(1.1); /* slightly larger when happy */
}

#robot-face.speaking .blush-cheek {
    opacity: 0.28;
}

#robot-face.sleepy .blush-cheek {
    opacity: 0.06; /* dimmer/almost completely hidden when sleeping */
}

#robot-face.confused .blush-cheek {
    opacity: 0.10;
}

/* Eyes */
.eye-white {
    fill: var(--eye-white);
}

.eye-iris {
    fill: var(--eye-iris);
    transition: cx 0.15s ease, cy 0.15s ease, transform var(--transition-normal);
}

.eye-pupil {
    fill: var(--eye-pupil);
    transition: cx 0.15s ease, cy 0.15s ease, transform var(--transition-normal);
}

.eye-shine {
    fill: var(--eye-shine);
    transition: cx 0.15s ease, cy 0.15s ease, transform var(--transition-normal);
}

/* Eyelid — for blinking and sleepy */
.eyelid {
    fill: var(--eyelid-color);
    transform-origin: center center;
    transform: translateY(-105px);
    transition: transform 0.15s ease, fill var(--transition-normal);
}

/* Happy eye curve path */
.eye-happy-curve {
    fill: none;
    stroke: var(--mouth-color);
    stroke-width: 15;
    stroke-linecap: round;
    display: none; /* hidden by default */
}

/* Happy state */
.eye.happy .eye-white,
.eye.happy .eye-iris,
.eye.happy .eye-pupil,
.eye.happy .eye-shine,
.eye.happy .eyelid {
    display: none;
}

.eye.happy .eye-happy-curve {
    display: block;
}

/* Confused state (asymmetric eyebrow tilt) */
#left-eyebrow {
    transform-origin: 260px 80px;
}
#right-eyebrow {
    transform-origin: 540px 80px;
}

.robot-face.confused #left-eyebrow {
    transform: translateY(12px) rotate(-15deg);
}

.robot-face.confused #right-eyebrow {
    transform: translateY(-15px) rotate(15deg);
}

/* Surprised state (eyebrows up, pupils scaled down) */
.robot-face.surprised #left-eyebrow,
.robot-face.surprised #right-eyebrow {
    transform: translateY(-30px);
}

.robot-face.surprised .eye-iris,
.robot-face.surprised .eye-pupil {
    transform: scale(0.6);
}

.robot-face.surprised #left-eye .eye-iris,
.robot-face.surprised #left-eye .eye-pupil {
    transform-origin: 270px 210px;
}

.robot-face.surprised #right-eye .eye-iris,
.robot-face.surprised #right-eye .eye-pupil {
    transform-origin: 530px 210px;
}

/* Blink animation */
.eye.blink .eyelid {
    animation: blinkAnim 0.2s ease-in-out;
}

@keyframes blinkAnim {
    0%   { transform: translateY(-105px); }
    45%  { transform: translateY(0px); }
    55%  { transform: translateY(0px); }
    100% { transform: translateY(-105px); }
}

/* Sleepy eyelids — half closed */
.eye.sleepy .eyelid {
    transform: translateY(-30px);
    transition: transform 1.5s ease;
}

/* Sleepy peek — eyes open slightly */
.eye.sleepy-peek .eyelid {
    transform: translateY(-50px);
    transition: transform 1s ease;
}

/* Full closed (yawn) */
.eye.closed .eyelid {
    transform: translateY(0px);
    transition: transform 0.8s ease;
}

/* Mouth */
.mouth {
    fill: none;
    stroke: var(--mouth-color);
    stroke-width: 6;
    stroke-linecap: round;
    transition: d 0.4s ease;
}

/* Mouth states via CSS classes — JS will update the `d` attribute */

/* Question marks */
.question-marks.hidden {
    display: none;
}

.qmark {
    font-family: var(--font-family);
    font-size: 42px;
    font-weight: 700;
    fill: var(--mouth-color);
    opacity: 0;
}

.question-marks.visible .q1 {
    animation: qmarkFloat 1.2s ease-in-out infinite;
}
.question-marks.visible .q2 {
    animation: qmarkFloat 1.2s ease-in-out 0.3s infinite;
}
.question-marks.visible .q3 {
    animation: qmarkFloat 1.2s ease-in-out 0.6s infinite;
}

@keyframes qmarkFloat {
    0%   { opacity: 0; transform: translateY(10px); }
    30%  { opacity: 1; }
    70%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-15px); }
}



/* Speaking mouth animation */
.mouth.speaking {
    animation: speakingMouth 0.35s ease-in-out infinite alternate;
}

@keyframes speakingMouth {
    0%   { stroke-width: 6; }
    100% { stroke-width: 10; }
}

/* ============================================
   MICROPHONE & NOISE INDICATORS
   ============================================ */
.bottom-controls {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100;
}

.mic-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: 50px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    cursor: pointer;
}

.mic-indicator:hover {
    background: rgba(0,0,0,0.7);
    transform: scale(1.05);
}

.mic-indicator.listening {
    color: var(--mic-active);
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.15);
    animation: micPulse 1.5s ease-in-out infinite;
}

.mic-indicator.inactive {
    color: var(--mic-inactive);
    box-shadow: 0 0 20px rgba(255, 59, 59, 0.15);
    animation: none;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(57, 255, 20, 0.1); }
    50%      { box-shadow: 0 0 35px rgba(57, 255, 20, 0.3); }
}

.mic-label {
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Noise Warning Indicator (Option 3) */
.noise-warning {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: 50px;
    background: rgba(255, 107, 53, 0.15);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 107, 53, 0.3);
    color: #FF6B35;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    animation: noisePulse 2s infinite alternate;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

@keyframes noisePulse {
    0% {
        box-shadow: 0 0 10px rgba(255, 107, 53, 0.15);
        transform: scale(1);
    }
    100% {
        box-shadow: 0 0 22px rgba(255, 107, 53, 0.35);
        transform: scale(1.02);
    }
}

.noise-warning.hidden {
    display: none !important;
}

.noise-wave {
    animation: noiseWaveAnim 1.2s infinite ease-in-out;
    transform-origin: left center;
}

.noise-wave:nth-child(3) {
    animation-delay: 0.2s;
}

.noise-wave:nth-child(4) {
    animation-delay: 0.5s;
}

@keyframes noiseWaveAnim {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.9);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* ============================================
   UTILITY & ANIMATIONS
   ============================================ */
.hidden {
    display: none !important;
}

/* Ambient background glow */
.robot-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vw;
    height: 60vh;
    background: radial-gradient(ellipse, var(--accent-glow), transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: ambientGlow 6s ease-in-out infinite;
}

@keyframes ambientGlow {
    0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
    50%      { opacity: 0.6; transform: translate(-50%, -50%) scale(1.05); }
}

.robot-face-wrapper {
    position: relative;
    z-index: 1;
}

/* Scrollbar for modal */
.modal-card::-webkit-scrollbar {
    width: 6px;
}
.modal-card::-webkit-scrollbar-track {
    background: transparent;
}
.modal-card::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 500px) {
    .modal-card {
        padding: 24px 20px;
        border-radius: 20px;
    }
    .color-btn {
        min-width: 56px;
        padding: 8px 6px;
    }
    .color-label {
        font-size: 0.6rem;
    }
    .swatch {
        width: 22px;
        height: 22px;
    }
}


/* ============================================
   CONTEXTUAL EFFECTS (Love, Hot, Cold)
   ============================================ */
   
/* Freeze Effect */
.effect-cold #face-bg {
    fill: #bce3ff !important;
    transition: fill 2s ease !important;
}

/* Hot Effect (Sweat drops) */
.effect-hot #sweat-drops {
    display: block !important;
}
.effect-hot .sweat-drop {
    animation: sweatDrip 1.5s infinite;
}
.effect-hot .sweat-drop:nth-child(2) {
    animation-delay: 0.75s;
}

@keyframes sweatDrip {
    0% { transform: translateY(0) scale(0.8); opacity: 0; }
    20% { opacity: 0.8; }
    80% { transform: translateY(80px) scale(1); opacity: 0.8; }
    100% { transform: translateY(100px) scale(1); opacity: 0; }
}

/* Love Effect (Floating Hearts) */
.floating-heart {
    animation: floatHeart 2s forwards ease-in;
    transform-origin: center;
}

@keyframes floatHeart {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    15% { opacity: 0.9; transform: translateY(-20px) scale(1.1); }
    80% { opacity: 0.8; transform: translateY(-120px) scale(0.8); }
    100% { transform: translateY(-150px) scale(0.5); opacity: 0; }
}

