/* static/css/main.css */
/* Improved mobile layout with Safari-specific fixes */
:root {
    --sat: env(safe-area-inset-top);
    --sar: env(safe-area-inset-right);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0; /* Base padding, JS might add more for mobile gaps */
    overflow: hidden;
    font-family: sans-serif;
    box-sizing: border-box; /* Apply border-box to html and body for easier size calculations with padding */
}

*, *::before, *::after {
    box-sizing: inherit; /* Inherit box-sizing */
}


body {
    height: 100vh; /* Fallback for older browsers */
    height: -webkit-fill-available; /* iOS Safari */
    height: fill-available; /* Standard */
    height: 100dvh; /* Dynamic viewport height */
    display: flex; /* Used for main chat layout once loaded */
    flex-direction: column;
    background-color: #f3f4f6; /* Tailwind gray-100 */
}

/* Styles for the initial auth loading message */
#auth-loading-message {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100%; /* Full viewport before chat loads */
    width: 100%;
    font-size: 1.2em;
    color: #4b5563; /* Tailwind gray-600 */
    padding: 20px;
    /* box-sizing: border-box; inherited */
}

/* Main chat interface wrapper */
#main-chat-interface-wrapper {
    /* Starts hidden, JS will show it as 'display: flex' */
    flex-direction: column;
    height: 100%; /* Takes full height of its parent (body's content area) */
    width: 100%;
    padding: var(--sat) var(--sar) var(--sab) var(--sal); /* Device safe area padding */
    /* box-sizing: border-box; inherited */
    transition: filter 0.3s ease-in-out; /* For blur effect */
}

    #main-chat-interface-wrapper.main-content-defocused {
        filter: blur(3px);
        /* pointer-events: none; Overlay handles blocking interactions */
    }


#chat-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    padding-bottom: 0;
}

.message-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    margin-bottom: 0.75rem;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 2px 4px rgba(0,0,0,0.07);
    position: relative;
    white-space: pre-line; /* ADDED for multi-line support */
}

.user-message {
    background-color: #3b82f6; /* Tailwind blue-500 */
    color: white;
    margin-left: auto;
    margin-right: 0;
}

.ai-message {
    background-color: #ffffff;
    color: #1f2937; /* Tailwind gray-800 */
    margin-right: auto;
    margin-left: 0;
    border: 1px solid #e5e7eb;
}

.error-message.message-bubble {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.user-message.audio-message-container .transcript-content {
    color: #eff6ff; /* Lighter for dark blue bubble */
}

.ai-message.audio-message-container .transcript-content {
    color: #4b5563; /* Darker for light bubble */
}

header {
    /* padding-top removed as main wrapper handles safe area top */
}

footer {
    /* padding-bottom removed as main wrapper handles safe area bottom */
    position: sticky;
    bottom: 0; /* Stays at the bottom of the chat wrapper */
    background: white;
    border-top: 1px solid #e5e7eb;
    z-index: 20;
}

.audio-message-container {
    /* Styles specific to bubbles containing audio */
}

#prompt-input {
    min-height: 44px; /* Good for tap targets */
}

.quality-selector {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

    .switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

    .slider:before {
        position: absolute;
        content: "";
        height: 14px;
        width: 14px;
        left: 3px;
        bottom: 3px;
        background-color: white;
        transition: .4s;
        border-radius: 50%;
    }

input:checked + .slider {
    background-color: #2563eb;
}

input:focus + .slider {
    box-shadow: 0 0 1px #2563eb;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.search-loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-left: 5px;
    vertical-align: middle;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.playback-error-span {
    color: #b91c1c;
    font-size: 0.75rem;
    font-style: italic;
    margin-left: 5px;
    display: block;
    margin-top: 0.25rem;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    height: 1.2em;
}

    .typing-indicator span {
        height: 8px;
        width: 8px;
        margin: 0 2px;
        background-color: #9ca3af;
        border-radius: 50%;
        display: inline-block;
        animation: typing 1.4s infinite ease-in-out both;
    }

        .typing-indicator span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .typing-indicator span:nth-child(2) {
            animation-delay: -0.16s;
        }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1.0);
    }
}

.fade-in {
    animation: fadeInAnimation 0.5s ease-in forwards;
    opacity: 0;
}

@keyframes fadeInAnimation {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.ai-thinking-bubble {
    display: inline-block;
    padding: 0.5rem 0.75rem;
}

.transcript-content {
    min-height: 1.2em;
}

@keyframes highlight-fade-out {
    from {
        background-color: #fef3c7; /* Light yellow highlight */
    }

    to { /* Fades to original bubble color */
    }
}

.highlight-new.user-message, .highlight-new.ai-message {
    animation: highlight-fade-out 2s ease-out forwards;
}

@keyframes pulse-opacity-animation {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.animate-pulse-opacity {
    animation: pulse-opacity-animation 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.hidden {
    display: none !important;
}

#recording-controls {
    display: none;
}
    /* Toggled by JS */
    #recording-controls.flex {
        display: flex;
    }

#input-row {
    display: none;
}
    /* Toggled by JS */
    #input-row.flex {
        display: flex;
    }

/* New Modal Styles */
#modal-overlay {
    /* display: none; set by .hidden */
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
}

#settings-modal {
    /* display: none; set by .hidden */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 1.5rem; /* p-6 */
    border-radius: 0.5rem; /* rounded-lg */
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04); /* shadow-xl */
    z-index: 50;
    width: 91.666667%; /* w-11/12 */
    max-width: 28rem; /* max-w-md */
}
/* NEW STYLE for ai.prompts link */
.ai-prompts-link {
    font-size: 0.7rem;
    color: #6b7280; /* Tailwind gray-500 */
    text-decoration: underline;
    cursor: pointer;
    display: block;
    text-align: right;
    margin-top: 4px;
}
