:root {
    --widget-bg-color: #FFFFFF;
    --header-gradient-start: #a98b57; 
    --header-gradient-end: #d4ba8a; 
    --header-text-color: #3D3526; 
    --online-indicator-color: #6A994E; 
    --message-area-bg: #FFFFFF;
    --assistant-bubble-bg: #F8F5EE; 
    --assistant-text-color: #050505;
    --user-bubble-bg: #d4ba8a; 
    --user-text-color: #3D3526; 
    --quick-reply-border: #d4ba8a;
    --quick-reply-text: #a98b57;
    --quick-reply-bg: #FFFFFF;
    --quick-reply-bg-hover: #F8F5EE;
    --quick-reply-bg-active: #d4ba8a;
    --quick-reply-text-active: #3D3526;
    --input-placeholder-color: #9E9382;
    --input-text-color: #212529;
    --input-area-border-color: #E8E2D7; 
    --send-button-gradient-start: #a98b57;
    --send-button-gradient-end: #d4ba8a;
    --icon-color: #6F6350; 
    --widget-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    --widget-border-radius: 20px;
    --dropdown-bg: #FFFFFF;
    --dropdown-shadow: 0 4px 12px rgba(0,0,0,0.1);
    --dropdown-item-hover-bg: #F8F5EE;
    --dropdown-text-color: #212529;
    --code-bg: #E8E2D7;
    --code-text: #212529;
    --link-color: #a98b57;
    --body-bg: #F5F1E9; 
    --dark-mode-toggle-bg: #F8F5EE;
    --dark-mode-toggle-icon: #6F6350;
    --dark-mode-toggle-bg-hover: #E8E2D7;
}

html[data-theme="dark"] {
    --widget-bg-color: #2A251E; 
    --header-gradient-start: #a98b57;
    --header-gradient-end: #c4a877;
    --header-text-color: #F5F1E9; 
    --message-area-bg: #2A251E;
    --assistant-bubble-bg: #383228; 
    --assistant-text-color: #EAE3D9; 
    --user-bubble-bg: #a98b57;
    --user-text-color: #F5F1E9; 
    --quick-reply-border: #d4ba8a;
    --quick-reply-text: #d4ba8a;
    --quick-reply-bg: #383228;
    --quick-reply-bg-hover: #4A4236;
    --quick-reply-bg-active: #d4ba8a;
    --quick-reply-text-active: #3D3526;
    --input-placeholder-color: #A19582; 
    --input-text-color: #EAE3D9;
    --input-area-border-color: #4A4236;
    --send-button-gradient-start: #a98b57;
    --send-button-gradient-end: #c4a877;
    --icon-color: #BDB2A2; 
    --widget-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    --dropdown-bg: #383228;
    --dropdown-shadow: 0 4px 12px rgba(0,0,0,0.25);
    --dropdown-item-hover-bg: #4A4236;
    --dropdown-text-color: #EAE3D9;
    --code-bg: #383228;
    --code-text: #EAE3D9;
    --link-color: #e9d8b4;
    --body-bg: #1A1610; 
    --dark-mode-toggle-bg: #383228;
    --dark-mode-toggle-icon: #BDB2A2;
    --dark-mode-toggle-bg-hover: #4A4236;
}

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: 'Roboto', Arial, sans-serif;
    background-color: var(--body-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

.chat-widget {
    width: 700px;
    height: 800px;
    max-height: 90vh;
    background-color: var(--widget-bg-color);
    border-radius: var(--widget-border-radius);
    box-shadow: var(--widget-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 10;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.widget-header {
    background: linear-gradient(135deg, var(--header-gradient-start), var(--header-gradient-end));
    color: var(--header-text-color);
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    position: relative;
    border-top-left-radius: var(--widget-border-radius);
    border-top-right-radius: var(--widget-border-radius);
    z-index: 10;
    padding-bottom: 45px;
    transition: background 0.3s ease;
}

.widget-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30px;
    background-color: var(--message-area-bg);
    border-top-left-radius: 50% 20px;
    border-top-right-radius: 50% 20px;
    transform: translateY(1px);
    transition: background-color 0.3s ease;
}

.header-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.header-avatar-title {
    display: flex;
    align-items: center;
}

.header-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #FFF; 
    margin-right: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.5);
}

.header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--header-text-color); 
}

.header-actions {
    display: flex;
    align-items: center;
    position: relative;
}

.header-actions .icon-button {
    background: none;
    border: none;
    color: var(--header-text-color);
    padding: 7px;
    margin-left: 12px;
    cursor: pointer;
    opacity: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.header-actions .icon-button:hover {
    opacity: 1;
    background-color: rgba(255,255,255,0.1);
}

.header-actions .icon-button svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

#darkModeToggle {
    margin-left: 0; 
    padding: 8px;
    background-color: var(--dark-mode-toggle-bg);
    border-radius: 50%;
    color: var(--dark-mode-toggle-icon);
    transition: background-color 0.2s ease, color 0.2s ease;
}

#darkModeToggle:hover {
    background-color: var(--dark-mode-toggle-bg-hover);
}

.header-status-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    opacity: 0; 
    max-height: 0; 
    overflow: hidden;
    transition: opacity 0.4s ease, max-height 0.4s ease, margin-top 0.4s ease;
    color: var(--header-text-color);
    position: relative;
    z-index: 1;
    padding: 0 15px; 
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.15); 
}

.header-status-row.active {
    opacity: 1;
    max-height: 40px; 
    margin-top: 15px; 
    padding: 6px 15px; 
}

.header-status-row .icon {
    margin-right: 8px;
    font-size: 1rem;
}

.online-indicator {
    width: 10px;
    height: 10px;
    background-color: var(--online-indicator-color);
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 6px var(--online-indicator-color);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background-color: var(--dropdown-bg);
    border-radius: 8px;
    box-shadow: var(--dropdown-shadow);
    padding: 8px 0;
    z-index: 100;
    min-width: 190px;
    list-style: none;
    margin: 0;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.dropdown-menu.active { display: block; }

.dropdown-menu li {
    padding: 10px 18px;
    font-size: 0.95rem;
    color: var(--dropdown-text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s ease, color 0.3s ease;
}

.dropdown-menu li:hover { background-color: var(--dropdown-item-hover-bg); }

.dropdown-menu li .flag-icon {
    width: 22px;
    height: 22px; 
    margin-right: 12px;
    border: 1px solid #DDD;
    border-radius: 50%; 
    object-fit: cover; 
    flex-shrink: 0;
}

.chat-messages-container {
    flex-grow: 1;
    background-color: var(--message-area-bg);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
    position: relative;
    z-index: 1;
    transition: background-color 0.3s ease;
}

.chat-messages-container::-webkit-scrollbar { display: none; }
.chat-messages-container { -ms-overflow-style: none; scrollbar-width: none; }

.message-wrapper { display: flex; flex-direction: column; max-width: 85%; }

.message-bubble {
    margin-top: 0;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: flex-start;
}

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

.assistant-message .message-bubble {
    background-color: var(--assistant-bubble-bg);
    color: var(--assistant-text-color);
    border-bottom-left-radius: 6px;
}

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

.user-message .message-bubble {
    background-color: var(--user-bubble-bg);
    color: var(--user-text-color);
    border-bottom-right-radius: 6px;
}

.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul, .message-bubble ol { padding-left: 20px; margin: 0.5em 0; }
.message-bubble li { margin-bottom: 0.25em; }
.message-bubble a { color: var(--link-color); text-decoration: underline; transition: color 0.3s ease; }

.message-bubble code {
    background-color: var(--code-bg); 
    color: var(--code-text);
    padding: 0.2em 0.4em; 
    border-radius: 4px; 
    font-size: 0.9em;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.message-bubble pre {
    background-color: var(--code-bg); 
    color: var(--code-text);
    padding: 0.8em; 
    border-radius: 6px; 
    overflow-x: auto; 
    margin: 0.5em 0;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.message-bubble pre code { background-color: transparent; padding: 0; }
.message-bubble h1, .message-bubble h2, .message-bubble h3 { margin-top: 0.8em; margin-bottom: 0.4em; line-height: 1.3; }

.message-animation { animation: fadeIn 0.3s ease-out; }

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

.message-text-content {
    flex-grow: 1;
    word-break: break-word;
}

.tts-stop-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    margin-left: 8px;
    cursor: pointer;
    opacity: 0.6;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.tts-stop-icon:hover {
    opacity: 1;
}

/* ============================================
   WIDGET INPUT AREA - Base Styles
   ============================================ */
.widget-input-area {
    background-color: var(--widget-bg-color);
    padding: 15px 20px;
    border-top: 1px solid var(--input-area-border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    min-height: 5.5em;
    height: 5.5em;
    max-height: 5.5em;
    z-index: 5;
    border-bottom-left-radius: var(--widget-border-radius);
    border-bottom-right-radius: var(--widget-border-radius);
    transition: background-color 0.3s ease, border-top-color 0.3s ease;
}

.widget-input-area .input-wrapper {
    flex-grow: 1;
    position: relative;
    display: none; /* Hidden by default - voice mode is default */
    align-items: center;
}

.widget-input-area .icon-button { 
    background: none; 
    border: none; 
    padding: 8px; 
    cursor: pointer; 
    color: var(--icon-color); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    flex-shrink: 0; 
    transition: color 0.3s ease; 
}

.widget-input-area .icon-button:hover svg { fill: var(--send-button-gradient-start); }
.widget-input-area .icon-button svg { width: 24px; height: 24px; fill: currentColor; transition: fill 0.2s ease-in-out; }

.widget-input-area input[type="text"] {
    flex-grow: 1; 
    border: none; 
    outline: none; 
    background-color: transparent;
    font-size: 1rem; 
    color: var(--input-text-color); 
    padding: 10px 0;
    min-height: 24px;  
    height: auto;     
    font-family: 'Roboto', Arial, sans-serif;
    transition: color 0.3s ease, opacity 0.2s ease;
}

.widget-input-area input[type="text"]::placeholder { 
    color: var(--input-placeholder-color); 
    font-weight: 400; 
    transition: color 0.3s ease; 
}

/* Small voice button (used in text mode) */
.voice-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--send-button-gradient-start), var(--send-button-gradient-end));
    color: white;
    border: none;
    cursor: pointer;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 3px 8px rgba(169, 139, 87, 0.4);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, background 0.3s ease, opacity 0.2s ease;
}

.voice-button:hover {
    box-shadow: 0 4px 12px rgba(169, 139, 87, 0.5);
}

.voice-button svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.voice-button.hidden {
    display: none;
}

/* Send button */
.send-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--send-button-gradient-start), var(--send-button-gradient-end));
    color: white; 
    border: none; 
    cursor: pointer; 
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center; 
    flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(169, 139, 87, 0.4);
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out, background 0.3s ease;
}

.send-button:hover { 
    box-shadow: 0 4px 12px rgba(169, 139, 87, 0.5); 
}

.send-button:active { 
    transform: scale(0.95); 
    box-shadow: 0 2px 5px rgba(169, 139, 87, 0.3); 
}

.send-button svg { 
    width: 22px; 
    height: 22px; 
    fill: currentColor; 
}

.speech-status { display: none; }

/* ============================================
   TYPING INDICATOR
   ============================================ */
.message-wrapper .typing-dot {
    width: 8px;
    height: 8px;
    margin: 0 3px;
    background-color: var(--assistant-text-color);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.75); }
}

.mic-button.mic-active svg {
    fill: var(--accent-color, #a98b57);
}

/* ============================================
   MODAL STYLES
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: var(--widget-bg-color);
    color: var(--assistant-text-color);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    max-width: 450px;
    width: 90%;
    text-align: center;
    z-index: 1001;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 700;
    font-size: 1.35rem;
}

.modal-content p {
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 25px;
    opacity: 0.9;
}

.modal-content button {
    display: inline-block;
    padding: 12px 30px;
    font-size: 1rem;
    color: var(--header-text-color);
    background: linear-gradient(135deg, var(--send-button-gradient-start), var(--send-button-gradient-end));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal-content button:hover {
    opacity: 0.9;
}

.modal-content button:active {
    transform: scale(0.97);
}

/* ============================================
   TRASH/CANCEL CONTAINER
   ============================================ */
.trash-container {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
    z-index: 10;
}

.trash-container.active {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
    animation: trash-pulse 0.8s ease-in-out infinite;
}

@keyframes trash-pulse {
    0%, 100% { transform: translateY(-50%) scale(1.1); }
    50% { transform: translateY(-50%) scale(1.2); }
}

.trash-container.closing {
    animation: trash-close 0.4s ease-out forwards;
}

@keyframes trash-close {
    0% { transform: translateY(-50%) scale(1.1); opacity: 1; }
    50% { transform: translateY(-50%) scale(1.3); opacity: 1; }
    100% { transform: translateY(-50%) scale(0); opacity: 0; }
}

.trash-icon {
    width: 26px;
    height: 26px;
    fill: white;
}

.trash-container.active .trash-lid {
    animation: lid-open 0.3s ease-out forwards;
}

@keyframes lid-open {
    0% { transform: rotate(0deg) translateY(0); }
    100% { transform: rotate(-25deg) translateY(-2px); }
}

/* ============================================
   SPEECH RECOGNITION OVERLAY (for text mode recording)
   ============================================ */
#speechRecognitionOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--widget-bg-color);
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 6;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-bottom-left-radius: var(--widget-border-radius);
    border-bottom-right-radius: var(--widget-border-radius);
}

.widget-input-area.recording #speechRecognitionOverlay {
    display: flex;
    opacity: 1;
}

.recording-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background-color: #ef4444;
    border-radius: 50%;
    animation: recording-blink 1s ease-in-out infinite;
}

@keyframes recording-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.recording-timer-viber {
    font-size: 1rem;
    font-weight: 500;
    color: var(--input-text-color);
    min-width: 40px;
}

.cancel-zone {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--input-placeholder-color);
    font-size: 0.9rem;
    opacity: 0.8;
}

.cancel-arrow {
    font-size: 1.2rem;
    animation: arrow-slide 1s ease-in-out infinite;
}

@keyframes arrow-slide {
    0%, 100% { transform: translateX(0); opacity: 0.5; }
    50% { transform: translateX(-5px); opacity: 1; }
}

/* Recording state for small mic button */
.voice-button.recording {
    transform: scale(1.2); 
    animation: opacity-pulse 2s infinite ease-in-out;
    z-index: 7; 
}

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

.voice-button.sliding {
    transition: transform 0.1s ease-out; 
}

/* ============================================
   UNIFIED VOICE MODE - Works on ALL devices
   ============================================ */

/* Voice Mode Container - VISIBLE BY DEFAULT ON ALL DEVICES */
.mobile-voice-mode {
    display: flex; /* Always visible by default */
    align-items: center;
    justify-content: flex-end;
    padding: 15px 20px;
    gap: 15px;
    position: relative;
    width: 100%;
}

/* Text Input Toggle Button - Left Side */
.text-input-toggle {
    width: 2.8em;
    height: 2.8em;
    min-width: 2.8em;
    min-height: 2.8em;
    border-radius: 0;
    border: none;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.text-input-toggle svg {
    width: 1.6em;
    height: 1.6em;
    fill: var(--send-button-gradient-start);
    transition: fill 0.2s ease, transform 0.2s ease;
}

.text-input-toggle:hover svg {
    fill: var(--send-button-gradient-end);
    transform: scale(1.1);
}

.text-input-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.text-input-toggle:active svg {
    fill: var(--send-button-gradient-start);
}

/* Voice Instruction Text - Center */
.voice-instruction {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: 0.85rem;
    color: var(--input-placeholder-color);
    transition: opacity 0.3s ease;
    font-weight: 400;
    white-space: nowrap;
    pointer-events: none;
    max-width: calc(100% - 180px);
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
}

/* Big Mic Button - Right Side */
.voice-button-big {
    width: 5em;
    height: 5em;
    min-width: 5em;
    min-height: 5em;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--send-button-gradient-start), var(--send-button-gradient-end));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(169, 139, 87, 0.3);
    margin-left: auto;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: none;
}

.voice-button-big svg {
    width: 2.5em;
    height: 2.5em;
    fill: var(--header-text-color);
    transition: width 0.3s ease, height 0.3s ease;
    pointer-events: none;
}

.voice-button-big:hover:not(.recording) {
    box-shadow: 0 6px 20px rgba(169, 139, 87, 0.45);
    transform: scale(1.02);
}

.voice-button-big:active:not(.recording) {
    transform: scale(0.95);
}

/* Big Mic Recording State - STABLE SIZE */
.voice-button-big.recording {
    width: 6em !important;
    height: 6em !important;
    min-width: 6em !important;
    min-height: 6em !important;
    background: linear-gradient(135deg, #c4a877, #e9d8b4) !important;
    animation: mic-pulse 1.5s infinite ease-in-out !important;
    box-shadow: 0 6px 25px rgba(169, 139, 87, 0.5) !important;
}

.voice-button-big.recording svg {
    width: 3em !important;
    height: 3em !important;
}

@keyframes mic-pulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 6px 25px rgba(169, 139, 87, 0.5);
    }
    50% { 
        transform: scale(1.05); 
        box-shadow: 0 8px 30px rgba(169, 139, 87, 0.7);
    }
}

/* Soundwave Animation - Center During Recording */
.mobile-soundwave {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    height: 40px;
    align-items: center;
    gap: 4px;
    z-index: 5;
    pointer-events: none;
}

.mobile-soundwave.active {
    display: flex;
}

.mobile-soundwave .soundwave-bar {
    width: 4px;
    background: linear-gradient(180deg, var(--send-button-gradient-start), var(--send-button-gradient-end));
    border-radius: 2px;
    animation: soundwave-animate 0.6s ease-in-out infinite;
    opacity: 0.9;
}

@keyframes soundwave-animate {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1); }
}

.mobile-soundwave .soundwave-bar:nth-child(1) { animation-delay: -0.5s; height: 10px; }
.mobile-soundwave .soundwave-bar:nth-child(2) { animation-delay: -0.4s; height: 15px; }
.mobile-soundwave .soundwave-bar:nth-child(3) { animation-delay: -0.3s; height: 20px; }
.mobile-soundwave .soundwave-bar:nth-child(4) { animation-delay: -0.2s; height: 25px; }
.mobile-soundwave .soundwave-bar:nth-child(5) { animation-delay: -0.1s; height: 30px; }
.mobile-soundwave .soundwave-bar:nth-child(6) { animation-delay: 0s; height: 25px; }
.mobile-soundwave .soundwave-bar:nth-child(7) { animation-delay: 0.1s; height: 20px; }
.mobile-soundwave .soundwave-bar:nth-child(8) { animation-delay: 0.2s; height: 15px; }
.mobile-soundwave .soundwave-bar:nth-child(9) { animation-delay: 0.3s; height: 10px; }

/* Hide instruction during recording */
.mobile-voice-mode.recording .voice-instruction {
    opacity: 0;
}

/* Dim text toggle during recording */
.mobile-voice-mode.recording .text-input-toggle {
    opacity: 0.3;
    pointer-events: none;
}

/* ============================================
   TEXT MODE - When user switches to text input
   ============================================ */

/* TEXT MODE: Hide voice mode UI */
.widget-input-area.text-mode .mobile-voice-mode {
    display: none !important;
}

/* TEXT MODE: Show input wrapper */
.widget-input-area.text-mode .input-wrapper {
    display: flex !important;
}

/* TEXT MODE: Show ONLY mic button initially (send hidden) */
.widget-input-area.text-mode .voice-button {
    display: flex !important;
    width: 50px;
    height: 50px;
}

/* TEXT MODE: Send button hidden by default */
.widget-input-area.text-mode .send-button {
    display: none !important;
}

/* TEXT MODE: When user types, show send button (hide mic) */
.widget-input-area.text-mode.has-text .voice-button {
    display: none !important;
}

.widget-input-area.text-mode.has-text .send-button {
    display: flex !important;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Mobile-specific adjustments */
@media (max-width: 600px) {
    body { 
        padding: 0; 
        align-items: flex-start; 
    }
    
    .chat-widget {
        width: 100%;
        height: 100vh;
        height: 100dvh; 
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }
    
    .widget-header, 
    .widget-input-area { 
        border-radius: 0; 
    }
    
    .widget-header::after { 
        border-top-left-radius: 30% 20px; 
        border-top-right-radius: 30% 20px; 
    }
    
    .header-title { font-size: 1.1rem; }
    .header-avatar { width: 40px; height: 40px; margin-right: 12px; }
    .widget-header { padding: 15px 18px 40px 18px; }
    .header-actions .icon-button svg { width: 22px; height: 22px; }
    
    .chat-messages-container {
        padding: 15px;
        gap: 12px;
        padding-bottom: 100px; 
    }
    
    .message-bubble { 
        padding: 10px 15px; 
        font-size: 0.9rem; 
    }
    
    .widget-input-area {
        padding: 12px 15px;
        gap: 10px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        box-sizing: border-box;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    
    .widget-input-area input[type="text"] { font-size: 0.95rem; }
    .widget-input-area .icon-button svg { width: 22px; height: 22px; }
    .send-button { width: 45px; height: 45px; }
    .send-button svg { width: 20px; height: 20px; }
    .voice-button { width: 45px; height: 45px; }
    .voice-button svg { width: 22px; height: 22px; }
    
    .cancel-zone {
        font-size: 0.8rem;
    }
    
    .voice-instruction {
        font-size: 0.8rem;
        max-width: calc(100% - 140px);
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .voice-instruction {
        font-size: 0.7rem;
        max-width: calc(100% - 120px);
    }
}

/* Tablet adjustments */
@media (min-width: 601px) and (max-width: 900px) {
    .chat-widget { 
        width: 450px; 
        height: 70vh; 
        max-height: 650px; 
    }
    
    .header-title { font-size: 1.15rem; }
    .widget-header { padding-bottom: 40px; }
}

/* Desktop adjustments */
@media (min-width: 901px) {
    .voice-button-big {
        width: 5.5em;
        height: 5.5em;
        min-width: 5.5em;
        min-height: 5.5em;
    }
    
    .voice-button-big.recording {
        width: 6.5em !important;
        height: 6.5em !important;
        min-width: 6.5em !important;
        min-height: 6.5em !important;
    }
    
    .voice-instruction {
        font-size: 0.9rem;
    }
}

/* ============================================
   DISABLED STATE STYLES
   ============================================ */
.widget-input-area.disabled .voice-button-big,
.widget-input-area.disabled .voice-button,
.widget-input-area.disabled .send-button,
.widget-input-area.disabled .text-input-toggle {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.widget-input-area.disabled input[type="text"] {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================
   FOCUS STATES FOR ACCESSIBILITY
   ============================================ */
.voice-button-big:focus-visible,
.voice-button:focus-visible,
.send-button:focus-visible,
.text-input-toggle:focus-visible {
    outline: 3px solid var(--send-button-gradient-start);
    outline-offset: 2px;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .widget-input-area,
    .widget-header {
        display: none;
    }
}
