: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;
        }
        .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); } }

        .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; /* em instead of px - scales with font size */
            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: flex;
            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; 
        }
        
        .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: flex;
            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 {
            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;
            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; }

        @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; }
        }
        @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; }
        }

        .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);
        }

        .speech-status {
            font-size: 0.75rem;
            color: var(--text-secondary-color);
            text-align: center;
            padding-top: 4px; 
            min-height: 1.2em;
            visibility: hidden;
        }

        .message-bubble {
            display: flex;
            align-items: flex-start;
        }

        .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;
        }

        .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;
            color: var(--header-gradient-start);
        }

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

        .modal-content button {
            padding: 12px 25px;
            border: none;
            border-radius: 5px;
            background: linear-gradient(135deg, var(--send-button-gradient-start), var(--send-button-gradient-end));
            color: var(--header-text-color);
            cursor: pointer;
            font-size: 1rem;
            font-weight: 500;
            transition: background 0.2s ease, transform 0.1s ease;
        }

        .modal-content button:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(169, 139, 87, 0.3);
        }

        .modal-content button:active {
            transform: translateY(0);
        }

        .message-wrapper {
            will-change: transform;
            contain: layout style paint;
        }

        .optimistic {
            opacity: 1;
            transition: opacity 0.2s;
        }

        .optimistic.confirmed {
            opacity: 1;
        }

        .partial-text {
            opacity: 0.6;
            font-style: italic;
            transition: opacity 0.2s ease;
        }

        .status-indicator {
            position: fixed;
            bottom: 80px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 0.85rem;
            z-index: 999;
            pointer-events: none;
        }

        .status-indicator.hidden {
            display: none;
        }

.widget-input-area {
    position: relative;
    overflow: hidden;
}

#speechRecognitionOverlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--widget-bg-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 6;
  gap: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out, background-color 0.3s ease;
}

@media (min-width: 601px) {
  #speechRecognitionOverlay {
    justify-content: flex-start;
    gap: 15px;
  }
  
  #speechRecognitionOverlay .cancel-zone {
    display: none;
  }
  
  #speechRecognitionOverlay .trash-container {
    display: none;
  }
}


.widget-input-area.recording .input-wrapper #userInput,
.widget-input-area.recording .input-wrapper .icon-button {
    opacity: 0;
    pointer-events: none;
}

.widget-input-area.recording #speechRecognitionOverlay {
    opacity: 1;
    pointer-events: all;
}

.recording-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.recording-dot {
    width: 10px;
    height: 10px;
    background-color: #ef4444; 
    border-radius: 50%;
    animation: pulse-opacity 1.5s infinite ease-in-out;
}

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

.recording-timer-viber {
    font-size: 1rem;
    font-weight: 400;
    color: var(--input-text-color);
    min-width: 45px;
    font-family: 'Roboto', sans-serif;
    transition: color 0.3s ease;
}

.cancel-zone {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--input-placeholder-color);
    font-size: 0.9rem;
    white-space: nowrap;
    transition: color 0.3s ease;
    flex-grow: 1;
    justify-content: center;
}

.cancel-arrow {
    font-size: 1.2rem;
    font-weight: 300;
}

.trash-container {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%) scale(0.5);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10;
    pointer-events: none;
}

.trash-container.active {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

.trash-icon {
    width: 32px;
    height: 32px;
}

.trash-icon .trash-body,
.trash-icon .trash-handle {
    fill: var(--icon-color);
    transition: fill 0.3s ease;
}

.trash-icon .trash-lid {
    fill: var(--send-button-gradient-start);
    transform-origin: center;
    transition: transform 0.2s ease-out, fill 0.3s ease;
}

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

@keyframes snap-close {
    0% { transform: rotate(-45deg); }
    50% { transform: rotate(-55deg); }
    100% { transform: rotate(0deg); }
}

.desktop-soundwave {
  display: none;
  flex-grow: 1;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 0 15px;
}

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

.soundwave-bar {
  width: 3px;
  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.8;
}

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

@keyframes soundwave-animate {
  0%, 100% { height: 5px; }
  50% { height: 20px; }
}

@media (max-width: 600px) {
  .desktop-soundwave {
    display: none !important;
  }
}

.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; 
}

@media (max-width: 600px) {
    .cancel-zone {
        font-size: 0.8rem;
    }
}

/* ============================================
   MOBILE VOICE MODE - Professional Implementation
   ============================================ */

/* Mobile Voice Mode Container */
.mobile-voice-mode {
    display: none;
    align-items: center;
    justify-content: flex-end; /* Push big mic to the right */
    padding: 15px 20px;
    gap: 15px;
    position: relative;
    width: 100%;
}

/* Text Input Toggle Button - Left Side */
.text-input-toggle {
    width: 2.8em; /* em instead of 45px */
    height: 2.8em;
    min-width: 2.8em;
    min-height: 2.8em;
    border-radius: 0; /* No round border */
    border: none; /* No border */
    background-color: transparent; /* Transparent background */
    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; /* No shadow */
}

.text-input-toggle svg {
    width: 1.6em; /* em instead of 26px */
    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.8rem; /* Smaller font - was 0.95rem */
    color: var(--input-placeholder-color);
    transition: opacity 0.3s ease;
    font-weight: 400;
    white-space: nowrap;
    pointer-events: none;
    max-width: calc(100% - 140px); /* Leave space for buttons */
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
}

/* Big Mic Button - Right Side */
.voice-button-big {
    width: 5em; /* em instead of 80px */
    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.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Do NOT transition width/height */
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(169, 139, 87, 0.3);
    margin-left: auto; /* Force to right */
}

.voice-button-big svg {
    width: 2.5em; /* em instead of 40px */
    height: 2.5em;
    fill: var(--header-text-color);
    transition: width 0.3s ease, height 0.3s ease;
}

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

/* Big Mic Recording State - STABLE SIZE */
.voice-button-big.recording {
    width: 6em !important; /* em instead of 95px */
    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; /* em instead of 48px */
    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);
    }
}

/* Mobile Soundwave - 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;
}

.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;
}

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

/* ============================================
   MOBILE MODE SWITCHING - Professional Logic
   ============================================ */

@media (max-width: 600px) {
    /* Show mobile voice mode by default */
    .mobile-voice-mode {
        display: flex;
    }
    
    /* VOICE MODE: Hide desktop input elements */
    .widget-input-area:not(.text-mode) .input-wrapper,
    .widget-input-area:not(.text-mode) .voice-button,
    .widget-input-area:not(.text-mode) .send-button,
    .widget-input-area:not(.text-mode) #speechRecognitionOverlay {
        display: none !important;
    }
    
    /* TEXT MODE: Hide mobile voice 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: 45px;
        height: 45px;
    }
    
    /* 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;
    }
}
