/* Color Palette for Dementia Care - Calming and Clear */
:root {
    --primary-color: #6B9BD1; /* Soft blue - calming */
    --secondary-color: #A8D5BA; /* Soft green - soothing */
    --accent-color: #F4A261; /* Warm orange - friendly */
    --bg-color: #F8F9FA; /* Very light gray */
    --text-color: #2C3E50; /* Dark blue-gray - good contrast */
    --light-text: #7F8C8D;
    --white: #FFFFFF;
    --error-color: #E74C3C;
    --success-color: #2ECC71;

    /* Voice states */
    --listening-color: #3498DB;
    --speaking-color: #9B59B6;
    --idle-color: #95A5A6;
    --active-color: #2ECC71;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: url('/static/calm-ocean-no-sphere.png') center center fixed;
    background-size: cover;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 18px; /* Larger text for better readability */
    position: relative;
    overflow-x: hidden;
    padding-top: 80px; /* Make room for fixed banner */
}

/* Date/Time Banner */
.date-time-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    border-bottom: 4px solid rgba(255, 255, 255, 0.3);
}

.banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bannerSlide 15s linear infinite;
}

.banner-content span {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    letter-spacing: 0.05em;
}

@keyframes bannerSlide {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-20%);
    }
}

/* Pause animation on hover */
.date-time-banner:hover .banner-content {
    animation-play-state: paused;
}

/* Remove old ocean animation overlay - using background image now */

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(64, 224, 208, 0.85); /* Light blue-turquoise */
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

h1 {
    font-family: 'Times New Roman', Times, serif;
    font-size: 2.5rem;
    color: #000000; /* Black */
    margin-bottom: 0.5rem;
}

.header-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 1rem 0;
}

.header-status .status-indicator {
    font-size: 2rem;
    color: var(--success-color);
    animation: blink 2s ease-in-out infinite;
}

.header-status .status-label {
    font-size: 1.3rem;
    font-weight: 600;
    color: #000000;
}

.subtitle {
    color: #000000; /* Black */
    font-size: 1.2rem;
    line-height: 1.6;
    max-width: 90%;
    margin: 0 auto;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Sphere and Controls Row - Side by Side Layout */
.sphere-controls-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

/* Voice Visualizer - The Dynamic Circle */
.voice-visualizer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}

/* 3D Sphere Styling */
.circle {
    position: relative;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
    transform-style: preserve-3d;
    perspective: 1000px;

    /* 3D sphere effect with radial gradient */
    background: radial-gradient(circle at 30% 30%,
        rgba(255, 255, 255, 0.8) 0%,
        rgba(168, 213, 186, 0.9) 20%,
        rgba(107, 155, 209, 1) 50%,
        rgba(50, 90, 150, 1) 80%,
        rgba(30, 50, 80, 1) 100%);

    /* 3D shadow for depth */
    box-shadow:
        inset -25px -25px 50px rgba(0, 0, 0, 0.3),
        inset 25px 25px 50px rgba(255, 255, 255, 0.2),
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

.circle.idle {
    background: radial-gradient(circle at 30% 30%,
        rgba(255, 255, 255, 0.7) 0%,
        rgba(135, 169, 200, 0.9) 20%,
        rgba(107, 155, 209, 1) 50%,
        rgba(80, 120, 170, 1) 80%,
        rgba(60, 90, 130, 1) 100%);
    transform: scale(1) rotateY(0deg);
}

.circle.listening {
    background: radial-gradient(circle at 30% 30%,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(93, 173, 226, 1) 20%,
        rgba(52, 152, 219, 1) 50%,
        rgba(41, 128, 185, 1) 80%,
        rgba(30, 90, 140, 1) 100%);
    animation: pulse3D 1.5s ease-in-out infinite;
    transform: scale(1.1) rotateY(15deg) rotateX(5deg);
}

.circle.speaking {
    background: radial-gradient(circle at 30% 30%,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(187, 143, 206, 1) 20%,
        rgba(155, 89, 182, 1) 50%,
        rgba(125, 60, 152, 1) 80%,
        rgba(90, 40, 110, 1) 100%);
    animation: wave3D 1s ease-in-out infinite;
    transform: scale(1.12) rotateY(-15deg) rotateX(-5deg);
}

.circle.processing {
    background: radial-gradient(circle at 30% 30%,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(248, 183, 57, 1) 20%,
        rgba(244, 162, 97, 1) 50%,
        rgba(220, 140, 80, 1) 80%,
        rgba(180, 100, 50, 1) 100%);
    animation: rotate3D 2s linear infinite;
}

.inner-circle {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.2);
}

.sphere-text {
    font-size: 1.8rem;
    font-weight: 600;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
    z-index: 10;
}

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.6);
    opacity: 0;
}

.circle.listening .pulse-ring {
    animation: pulse-ring 1.5s ease-out infinite;
}

/* 3D Animation Keyframes */
@keyframes pulse3D {
    0%, 100% {
        transform: scale(1.1) rotateY(15deg) rotateX(5deg);
        box-shadow:
            inset -25px -25px 50px rgba(0, 0, 0, 0.3),
            inset 25px 25px 50px rgba(255, 255, 255, 0.2),
            0 20px 60px rgba(52, 152, 219, 0.5),
            0 0 0 1px rgba(255, 255, 255, 0.2);
    }
    50% {
        transform: scale(1.15) rotateY(20deg) rotateX(8deg);
        box-shadow:
            inset -30px -30px 60px rgba(0, 0, 0, 0.4),
            inset 30px 30px 60px rgba(255, 255, 255, 0.3),
            0 25px 80px rgba(52, 152, 219, 0.7),
            0 0 0 2px rgba(255, 255, 255, 0.3);
    }
}

@keyframes wave3D {
    0%, 100% {
        transform: scale(1.12) rotateY(-15deg) rotateX(-5deg);
        border-radius: 50%;
    }
    25% {
        transform: scale(1.14) rotateY(-18deg) rotateX(-8deg);
        border-radius: 48% 52% 50% 50%;
    }
    50% {
        transform: scale(1.12) rotateY(-15deg) rotateX(-5deg);
        border-radius: 50% 50% 48% 52%;
    }
    75% {
        transform: scale(1.14) rotateY(-12deg) rotateX(-3deg);
        border-radius: 52% 48% 50% 50%;
    }
}

@keyframes rotate3D {
    from {
        transform: rotateY(0deg) rotateZ(0deg);
    }
    to {
        transform: rotateY(360deg) rotateZ(360deg);
    }
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.status-text {
    margin-top: 1.5rem;
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-color);
    text-align: center;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.voice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem 3rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--white);
    background: var(--primary-color);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(107, 155, 209, 0.3);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.voice-btn:hover {
    background: #5A8BC2;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(107, 155, 209, 0.4);
}

.voice-btn:active {
    transform: scale(0.95);
    background: var(--active-color);
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.5);
}

.voice-btn.active {
    background: var(--active-color);
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
    transform: scale(1.05);
}


/* Conversation Display */
.conversation {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

.user-message {
    align-self: flex-end;
}

.bot-message {
    align-self: flex-start;
}

.message-content {
    padding: 1.2rem 1.5rem;
    border-radius: 15px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.user-message .message-content {
    background: var(--primary-color);
    color: var(--white);
    border-bottom-right-radius: 5px;
}

.bot-message .message-content {
    background: rgba(232, 244, 248, 0.9);
    color: var(--text-color);
    border-bottom-left-radius: 5px;
    border: 1px solid rgba(38, 198, 218, 0.2);
}

.timestamp {
    font-size: 0.85rem;
    color: var(--light-text);
    padding: 0 0.5rem;
}

.user-message .timestamp {
    text-align: right;
}

/* Text Input */
.text-input-container {
    display: flex;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#textInput {
    flex: 1;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid #E0E0E0;
    border-radius: 10px;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

#textInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.send-btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--white);
    background: var(--accent-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.send-btn:hover {
    background: #E89451;
    transform: translateY(-1px);
}

/* Footer */
footer {
    margin-top: 2rem;
    padding: 2rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

footer .test-tts-btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--white);
    background: var(--success-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

footer .test-tts-btn:hover {
    background: #27AE60;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
}

footer .test-tts-btn:active {
    transform: translateY(0);
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Scrollbar Styling */
.conversation::-webkit-scrollbar {
    width: 8px;
}

.conversation::-webkit-scrollbar-track {
    background: #F0F0F0;
    border-radius: 10px;
}

.conversation::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.conversation::-webkit-scrollbar-thumb:hover {
    background: #5A8BC2;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.playback-btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    min-width: 100px;
}

.playback-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

/* Test Speaker Container */
.test-speaker-container {
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .sphere-controls-row {
        flex-direction: column;
        gap: 1rem;
    }

    .circle {
        width: 200px;
        height: 200px;
    }

    .inner-circle {
        width: 160px;
        height: 160px;
    }

    .message {
        max-width: 90%;
    }

    .voice-btn {
        padding: 1.2rem 2rem;
        font-size: 1rem;
    }
}
