/* --- THEME DEFINITIONS --- */

/* DEFAULT: AI FIESTA STYLE (New Theme) */
:root {
    --bg-color: #e8f9f7;
    /* Very Light Teal/White */
    /* Light, clean container */
    --container-bg: #ffffff;
    --text-color: #333333;
    --primary-neon: #18d48e;
    /* Bright Fiesta Green */
    /* Cyan Accent */
    --secondary-neon: #00bcd4;
    --border-color: rgba(24, 212, 142, 0.4);
    /* Soft, bright glow */
    --shadow-glow: 0 4px 20px rgba(0, 0, 0, 0.1), 0 0 5px rgba(24, 212, 142, 0.2);
    --user-bubble-bg: var(--secondary-neon);
    /* Cyan */
    --user-text: #ffffff;
    --bot-bubble-bg: #f3fcf9;
    /* Very light green-white */
    --bot-text: var(--text-color);
    --input-bg: #ffffff;
    --header-bg: #ffffff;
    --footer-text: #666666;
    --box-shadow-user: 0 4px 8px rgba(0, 0, 0, 0.1);
    --box-shadow-bot: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Red for recording */
    --voice-active: #ff4081;
    /* Color for the selected model in the list */
    --model-selected: #00bcd4;
}

/* 2. SIMPLE AESTHETIC WHITE (Alternative, kept for toggle function) */
.simple-theme {
    --bg-color: #f0f2f5;
    --container-bg: #ffffff;
    --text-color: #333333;
    --primary-neon: #4c4cff;
    --secondary-neon: #0084ff;
    --border-color: #dddddd;
    --shadow-glow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --user-bubble-bg: var(--secondary-neon);
    --user-text: #ffffff;
    --bot-bubble-bg: #e5e5e5;
    --bot-text: var(--text-color);
    --input-bg: #f5f5f5;
    --header-bg: #ffffff;
    --footer-text: #999999;
    --box-shadow-user: 0 2px 4px rgba(0, 0, 0, 0.1);
    --box-shadow-bot: 0 2px 4px rgba(0, 0, 0, 0.05);
    --voice-active: #cc0000;
    --model-selected: #0084ff;
}

/* --- FLUID ANIMATION STYLES (REMOVED for AI Fiesta look) --- */
/* The fluid animation styles are commented out or replaced to match the new clean UI. */
@keyframes fluid-float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(100px, -50px) rotate(60deg);
    }

    66% {
        transform: translate(-100px, 80px) rotate(120deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

.fluid-animation-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    /* Filter applied to the entire animation container */
    filter: blur(120px) contrast(1.2);
    opacity: 0.0;
    /* Set opacity to 0 to effectively disable the animation without removing the class */
}

.fluid-sphere-purple {
    position: absolute;
    border-radius: 50%;
    opacity: 0.7;
    animation-duration: 30s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-name: fluid-float;
    display: none;
    /* Explicitly hide the spheres for the clean look */
}

.sphere-p1 {
    width: 500px;
    height: 500px;
    background-color: var(--primary-neon);
    /* Bright Violet */
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.sphere-p2 {
    width: 700px;
    height: 700px;
    background-color: var(--secondary-neon);
    /* Magenta */
    bottom: -20%;
    right: -20%;
    animation-delay: -10s;
}

/* --- Global Styles --- */
body {
    font-size: 10px;
    /* Set global font size to 10px */
    font-family: 'Roboto', sans-serif;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.4s, color 0.4s;
    overflow: hidden;
}

.chat-container {
    width: 100%;
    max-width: 1024px;
    height: 90vh;
    background: var(--container-bg);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-glow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: all 0.4s;
}

/* Typing Animation Cursor */
#typing-span {
    border-right: 0.25em solid var(--primary-neon);
    /* Typing cursor/caret */
    animation: blink-caret 0.75s step-end infinite;
    /* Cursor blink */
}

@keyframes blink-caret {

    from,
    to {
        border-color: transparent
    }

    50% {
        border-color: var(--primary-neon);
    }
}

@keyframes pulse {

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

    50% {
        transform: scale(0.8);
        opacity: 0.5;
    }
}

@keyframes glitch {
    0% {
        text-shadow: 0.05em 0 0 var(--secondary-neon), -0.05em -0.025em 0 var(--primary-neon);
    }

    100% {
        text-shadow: none;
    }
}

/* --- Layout & Message Styles --- */
.chat-header {
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--header-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.chat-header h1 {
    font-size: 1.8em;
    color: var(--primary-neon);
    margin: 0;
    font-weight: 900;
    /* text-shadow: 0 0 8px var(--primary-neon), 0 0 15px var(--secondary-neon); */
    letter-spacing: 1px;
    /* animation: glitch 10s steps(10, end) infinite alternate; */
}

.controls {
    display: flex;
    gap: 8px;
    /* Added gap between control buttons */
}

.control-btn {
    background: var(--container-bg);
    border: 1px solid var(--primary-neon);
    border-radius: 4px;
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: var(--primary-neon);
    font-size: 1.1em;
    box-shadow: 0 0 10px rgba(24, 212, 142, 0.3);
    transition: all 0.2s;
}

.control-btn:hover {
    background: var(--primary-neon);
    color: var(--bg-color);
}

#chatbox {
    padding: 20px 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1;
    /* box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8); */
    z-index: 1;
    /* Above the fluid background */
    position: relative;
}

.message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 75%;
    word-wrap: break-word;
    line-height: 1.4;
    position: relative;
}

.message.user {
    background-color: var(--user-bubble-bg);
    color: var(--user-text);
    align-self: flex-end;
    margin-left: auto;
    box-shadow: var(--box-shadow-user);
}

.message.bot {
    background-color: var(--bot-bubble-bg);
    color: var(--bot-text);
    align-self: flex-start;
    margin-right: auto;
    border: 1px solid var(--border-color);
    box-shadow: var(--box-shadow-bot);
}

/* --- Action Buttons --- */
.message-actions {
    position: absolute;
    bottom: -30px;
    right: 0;
    left: 0;
    display: flex;
    justify-content: flex-start;
    /* Default for bot */
    gap: 5px;
    padding: 0 15px;
    pointer-events: auto;
}

.action-btn {
    background: none;
    border: none;
    color: var(--primary-neon);
    font-size: 0.8em;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.fa-thumbs-up {
    color: #5cb85c;
}

.fa-thumbs-down {
    color: #d9534f;
}

/* --- Input Form & Buttons --- */
#inputForm {
    display: flex;
    padding: 15px 25px;
    background: var(--input-bg);
    gap: 10px;
    border-top: 1px solid var(--border-color);
    z-index: 1;
    /* Above the fluid background */
}

#userInput {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid var(--primary-neon);
    border-radius: 25px;
    font-size: 1em;
    outline: none;
    background: var(--container-bg);
    color: var(--primary-neon);
    box-shadow: inset 0 0 8px rgba(24, 212, 142, 0.3);
    text-transform: none;
    letter-spacing: normal;
}

/* Style for Stop Icon */
#sendBtn .fa-stop {
    font-size: 1.2em;
    color: #ff4d4d;
    /* Red for stop (Square Icon ⬛) */
}

/* Style for Critical Error Feedback (429) */
.feedback.critical {
    background-color: #580000;
    /* Dark Red */
    border: 1px solid #ff4d4d !important;
    /* Bright Red Border (use !important to override other feedback styles) */
    color: #ff4d4d;
    font-weight: 700;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.8) !important;
    animation: critical-flash 0.5s infinite alternate;
}

@keyframes critical-flash {
    from {
        box-shadow: 0 0 10px rgba(255, 0, 0, 0.6) !important;
    }

    to {
        box-shadow: 0 0 20px rgba(255, 0, 0, 1) !important;
    }
}

#sendBtn,
#voiceBtn,
#uploadFileBtn {
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    align-self: center;
    transition: all 0.2s;
}

#sendBtn {
    background: var(--primary-neon);
    color: var(--bg-color);
    box-shadow: 0 0 15px var(--primary-neon);
    border: 1px solid var(--primary-neon);
}

#voiceBtn {
    background: var(--container-bg);
    color: var(--primary-neon);
    border: 1px solid var(--primary-neon);
    box-shadow: 0 0 10px var(--primary-neon);
}

/* Style for Staged/Active Upload Button */
#uploadFileBtn {
    background: var(--container-bg);
    color: var(--secondary-neon);
    border: 1px solid var(--secondary-neon);
    box-shadow: 0 0 8px var(--secondary-neon);
}

.chat-footer {
    background: var(--header-bg);
    color: var(--footer-text);
    padding: 8px 25px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    z-index: 1;
    /* Above the fluid background */
}

.chat-footer span {
    color: var(--primary-neon);
    font-weight: 700;
}

/* --- General Modal Styles (For Model Select) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-content {
    background: var(--container-bg);
    padding: 30px;
    border-radius: 12px;
    border: 2px solid var(--primary-neon);
    box-shadow: var(--shadow-glow);
    text-align: center;
    max-width: 400px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

@media screen and (min-width: 1024px) {
    .modal-content {
        max-width: 600px;
    }
}

.modal-content h2 {
    color: var(--primary-neon);
    margin: 0;
    font-size: 1.8em;
    text-shadow: 0 0 5px var(--primary-neon);
}

.modal-content p {
    color: var(--text-color);
    margin: 0;
}

.modal-content input[type="text"],
.modal-content input[type="password"] {
    padding: 12px 15px;
    border: 1px solid var(--primary-neon);
    border-radius: 8px;
    font-size: 1em;
    outline: none;
    background: var(--input-bg);
    color: var(--primary-neon);
    box-shadow: inset 0 0 8px rgba(24, 212, 142, 0.3);
}

.modal-content button[type="submit"] {
    background: var(--primary-neon);
    color: var(--bg-color);
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-content button[type="submit"]:hover {
    background: var(--secondary-neon);
    box-shadow: 0 0 15px var(--secondary-neon);
}

/* --- Model Selection Modal Specific Styles --- */
.model-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 350px;
    overflow-y: auto;
    padding: 10px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.model-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    text-align: left;
    border: 1px solid transparent;
    font-size: 1em;
}

.model-item:hover {
    background: rgba(24, 212, 142, 0.1);
    border-color: var(--primary-neon);
}

.model-item.selected {
    background: var(--model-selected);
    color: var(--user-text);
    font-weight: 700;
    box-shadow: 0 0 10px rgba(0, 188, 212, 0.5);
    border-color: var(--secondary-neon);
}

.model-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-name span {
    font-size: 0.8em;
    opacity: 0.7;
}

.model-status {
    font-size: 0.9em;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
}

.status-integrated {
    background: #5cb85c;
    color: white;
}
