/*
====================================================
 EMA-IMX Agent – Main Stylesheet
----------------------------------------------------
 This file contains all global and component styles for
 the EMA-IMX Agent web application. Sections are clearly
 marked for maintainability and onboarding.
====================================================
*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/*
----------------------------------------------------
 Initial Loading Overlay
----------------------------------------------------
*/
.initial-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.initial-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.initial-loading-content {
    text-align: center;
    color: white;
}

.initial-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.initial-loading-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    animation: pulse 1.5s ease-in-out infinite;
}
/* App Name in Initial Loading Overlay */
.app-name {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 18px;
    padding-bottom: 12px;
    letter-spacing: 1px;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/*
----------------------------------------------------
 Base Layout & Typography
----------------------------------------------------
*/
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: #f7f7f8;
    color: #2d3748;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    height: 100%;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
}

html {
    height: -webkit-fill-available;
} 

/*
----------------------------------------------------
 Header & Navigation
----------------------------------------------------
*/
header {
    padding: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    text-align: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.5px;
}

.library-selector-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    margin: 0 auto;
    max-width: fit-content;
}

.library-label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.library-selector {
    padding: 0.5rem 0.75rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    font-size: 0.9rem;
    font-weight: 500;
    color: #5a67d8;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.library-selector:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.library-selector:focus {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#chat-container {
    flex: 1;
    padding: 2rem;
    padding-bottom: calc(2rem - 50px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    width: 1000px;
    margin: 0 auto;
}

#chat-top-spacer {
    display: none;
}

footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/*
----------------------------------------------------
 Responsive Layouts
----------------------------------------------------
*/
@media (max-width: 1000px) {
    #chat-container {
        width: 100%;
        padding: 1rem;
    }
}

.input-area {
    padding: 0.3rem 2rem;
    display: none;
    transition: background-color 0.2s ease;
}

.input-area[data-mode="interview"] {
    background: linear-gradient(180deg, #ffffff 0%, #f6f7ff 100%);
}

.input-area[data-mode="chat"] {
    background: linear-gradient(180deg, #ffffff 0%, #ecfdf5 100%);
}

.start-chat-button {
    border: 0;
    border-radius: 999px;
    width: 50%;
    display: block;
    margin: 0 auto;
    padding: 0.8rem 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.start-chat-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.35);
}

.start-chat-button:active {
    transform: translateY(0);
}

/* Disabled input-area style */
.input-area.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.7);
}

/* ----------------------------------------------------
   Mobile Layout Adjustments
---------------------------------------------------- */
@media (max-width: 768px) {
    body {
        overscroll-behavior: auto;
        position: fixed;
        width: 100%;
    }
    
    .content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .library-selector-container {
        margin: 0 auto;
        padding: 0.6rem 1.2rem;
        gap: 0.4rem;
        box-shadow: 0 3px 8px rgba(102, 126, 234, 0.25);
    }
    
    .library-label {
        font-size: 0.85rem;
    }
    
    .library-selector {
        font-size: 0.8rem;
        padding: 0.35rem 0.5rem;
    }
    

}

/* New-process button — anchored to the right of the header */
.new-process-btn {
    display: flex;
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border: 1.5px solid #667eea;
    border-radius: 999px;
    background: transparent;
    color: #667eea;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.new-process-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-color: transparent;
    transform: translateY(-50%) scale(1.04);
}

.new-process-btn i {
    font-size: 0.9rem;
}

/* On small screens hide the text label, keep only the icon */
@media (max-width: 480px) {
    .new-process-label {
        display: none;
    }
    .new-process-btn {
        padding: 0.35rem 0.5rem;
    }
}

.menu-toggle {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    z-index: 1001;
    background: transparent;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.menu-toggle:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: translateY(-50%) scale(1.05);
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #6366f1;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* ----------------------------------------------------
   Sidebar Controls and Result Panels
---------------------------------------------------- */
/*
----------------------------------------------------
 Agent Selector (Sidebar)
----------------------------------------------------
*/
.agent-selector-container {
    padding: 1rem 1.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.agent-selector-container label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4a5568;
}

.agent-selector {
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    background: #ffffff;
    color: #2d3748;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.agent-selector:hover {
    background-color: #ede9fe;
    border-color: #4f46e5;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.2);
}

.agent-selector:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/*
----------------------------------------------------
 Translation & Transcription Results
----------------------------------------------------
*/
.translation-result {
    background: #f0fdf4;
    border-left: 3px solid #22c55e;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    margin-top: 8px;
}

.translation-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #16a34a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.transcription-result {
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    margin-top: 8px;
}

.transcription-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #2563eb;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

/* ----------------------------------------------------
   Chat Thread, Sidebar, and Overlay
---------------------------------------------------- */
@media (max-width: 768px) {
    header {
        flex-wrap: nowrap;
        gap: 6px;
        padding: 0.75rem 1rem;
    }
}

.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: #ffffff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1002;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a202c;
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 2rem;
    color: #718096;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.close-sidebar:hover {
    background: #f7f7f8;
    color: #2d3748;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    padding-bottom: 1rem;
}

.footer-info {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
    flex-shrink: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: #2d3748;
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

.sidebar-link:hover {
    background: #f7f7f8;
    color: #6366f1;
}

.sidebar-link .icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.language-selector-container {
    padding: 1rem 1.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.language-selector-container label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4a5568;
}

.language-selector {
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    background: #ffffff;
    color: #2d3748;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.language-selector:hover {
    border-color: #6366f1;
    background: #f8f9ff;
}

.language-selector:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .sidebar {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }
    
    .sidebar-nav {
        padding-bottom: 2rem;
    }
    
    .footer-info {
        padding: 0.75rem 1rem;
        font-size: 0.85em !important;
    }
}

/*
----------------------------------------------------
 Scroll Indicator
----------------------------------------------------
*/
.scroll-indicator {
    position: fixed;
    bottom: 140px;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: #6366f1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
    transition: all 0.3s ease;
    z-index: 50;
}

.scroll-indicator.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.scroll-indicator:hover {
    background: #4f46e5;
    transform: scale(1.1);
}

.scroll-indicator svg {
    width: 24px;
    height: 24px;
    fill: white;
}

@media (max-width: 768px) {
    .scroll-indicator {
        bottom: 180px;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
}

/*
----------------------------------------------------
 Chat Message Bubbles
----------------------------------------------------
*/
.message {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    animation: fadeIn 0.3s ease-in;
    border-radius: 12px;
    max-width: 100%;
    margin: 0;
    width: 100%;
}

@media (max-width: 768px) {
    .message {
        padding: 0.75rem;
        gap: 0.5rem;
        flex-direction: column;
    }
    
    .message .message-icon {
        align-self: flex-start;
    }

    .message-icon-column {
        width: fit-content;
        display: inline-flex;
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .message-tts-row {
        width: fit-content;
        margin-bottom: 0;
        flex-shrink: 0;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.message.assistant {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    position: relative;
}

.message-icon-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    flex-shrink: 0;
}

.message-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.message.user .message-icon {
    background: #10b981;
    color: #ffffff;
}

.message.assistant .message-icon {
    background: #6366f1;
    color: #ffffff;
}

.message.assistant.role-agent-message .message-icon {
    background: #f59e0b;
    color: #ffffff;
}

.message-content {
    flex: 1;
    line-height: 1.5;
}

.message-axis-title {
    display: none;
    margin: 0 0 0.3rem;
    text-align: right;
    font-size: 0.76rem;
    font-weight: 700;
    color: #5b6475;
}

.message.assistant .message-content {
    overflow: visible;
}

.message.assistant .message-axis-title {
    position: absolute;
    top: 0;
    right: 1rem;
    transform: translateY(-50%);
    margin: 0;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(91, 100, 117, 0.35);
    background: #f8fafc;
    line-height: 1.2;
    z-index: 1;
    /* Keep long axis labels on one line and avoid overlapping the icon area. */
    max-width: calc(100% - 5.25rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.message-text {
    margin-bottom: 0.35rem;
}

.axis-switch-notice {
    display: inline-block;
    margin: 0 0 0.45rem;
    padding: 0.08rem 0.5rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-style: italic;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: #5b6475;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.phase-separator {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
}
.phase-separator::before,
.phase-separator::after {
    content: '';
    flex: 1;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(to right, transparent, #c7d2fe 40%, #c7d2fe 60%, transparent);
}
.phase-separator-label {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.9rem;
    background: linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);
    color: #4338ca;
    border: 1.5px solid rgba(99, 102, 241, 0.28);
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    box-shadow: 0 1px 5px rgba(99, 102, 241, 0.13);
}

/* Phase-specific overrides */
.phase-separator[data-phase="chat"] .phase-separator-label {
    background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
    color: #047857;
    border-color: rgba(5, 150, 105, 0.28);
    box-shadow: 0 1px 5px rgba(5, 150, 105, 0.13);
}
.phase-separator[data-phase="chat"]::before,
.phase-separator[data-phase="chat"]::after {
    background: linear-gradient(to right, transparent, #6ee7b7 40%, #6ee7b7 60%, transparent);
}

.phase-separator[data-phase="final"] .phase-separator-label {
    background: linear-gradient(135deg, #fef9c3 0%, #fef3c7 100%);
    color: #92400e;
    border-color: rgba(180, 83, 9, 0.28);
    box-shadow: 0 1px 5px rgba(180, 83, 9, 0.13);
}
.phase-separator[data-phase="final"]::before,
.phase-separator[data-phase="final"]::after {
    background: linear-gradient(to right, transparent, #fcd34d 40%, #fcd34d 60%, transparent);
}

.phase-separator[data-phase="recap"] .phase-separator-label {
    background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    color: #1e40af;
    border-color: rgba(37, 99, 235, 0.28);
    box-shadow: 0 1px 5px rgba(37, 99, 235, 0.13);
}
.phase-separator[data-phase="recap"]::before,
.phase-separator[data-phase="recap"]::after {
    background: linear-gradient(to right, transparent, #93c5fd 40%, #93c5fd 60%, transparent);
}

.message-text img {
    max-width: 200px;
    width: 200px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    object-fit: cover;
    display: block;
    margin-bottom: 0.75rem;
}

/* Placeholder for broken images */
.broken-image-placeholder {
    max-width: 200px;
    width: 200px;
    height: 280px;
    background: #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.broken-image-placeholder i {
    font-size: 48px;
    color: #94a3b8;
}

/* Book recommendation sections */
.message-text h3 {
    margin-top: 0;
    margin-bottom: 0.15rem;
    color: #2d3748;
    font-size: 1.05em;

}

/* Author line directly after title */
.message-text h3 + p em,
.message-text h3 + p i {
    display: block;
    color: #718096;
    font-size: 0.95em;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

/* Reduced spacing between paragraphs */
.message-text p {
    margin-top: 0.35rem;
    margin-bottom: 0.35rem;
    line-height: 1.5;
}

/* Section headings in book recommendations */
.message-text p strong:first-child {
    color: #667eea;
    font-size: 1.05em;
    display: block;
    margin-top: 0.5rem;
    margin-bottom: 0.15rem;
}

/* Details list styling */
.message-text li strong:first-child {
    color: #667eea;
    font-size: 1.05em;
    display: block;
    margin-top: 0.5rem;
    margin-bottom: 0.15rem;
}
.message-text ul {
    list-style: none;
    padding-left: 0;
    margin: 0.25rem 0;
}

.message-text ul li {
    padding: 0.15rem 0;
    color: #4a5568;
    line-height: 1.4;
}

/* Final profile should keep explicit bullet markers for axis points */
.message-text.final-profile h3 {
    margin-top: 0;
    margin-bottom: 0.15rem;
    color: #667eea;
    font-size: 1.05em;

}
.message-text.final-profile ul {
    list-style: disc;
    padding-left: 1.25rem;
    margin: 0.35rem 0;
}

.message-text.final-profile ul li {
    padding: 0.2rem 0;
}

/* Recap blocks should keep explicit bullet markers */
.message-text.recap-block ul {
    list-style: disc;
    padding-left: 1.25rem;
    margin: 0.1rem 0;
}

.message-text.recap-block ul li {
    padding: 0.2rem 0;
}

/* Keep recap heading-to-list spacing tight to match source markdown. */
.message-text.recap-block p {
    margin-top: 0.1rem;
    margin-bottom: 0.1rem;
}

/* Style for borrow book link */
.message-text a[href*="pretnumerique.ca"] {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    margin: 0.75rem 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.message-text a[href*="pretnumerique.ca"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* Separator line between books */
.message-text hr {
    border: none;
    border-top: 3px solid #e2e8f0;
    margin: 1.5rem 0;
}

.message-text {
    margin-bottom: 0.35rem;
}

.message-disclaimer {
    font-size: 0.75rem;
    font-style: italic;
    color: #718096;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}

.message.user .message-disclaimer {
    display: none;
}



@media (max-width: 768px) {
    .input-area {
        padding: rem 1rem;
    }
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
}

.mode-pill-row {
    width: 100%;
    max-width: none;
    margin: 0.2rem auto 0;
    padding: 0.2rem 2rem 0.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-pill {
    display: flex;
    width: 100%;
    max-width: 800px;
    flex: 0 1 800px;
    box-sizing: border-box;
    margin: 0 auto;
    align-items: center;
    justify-content: center;
    gap: 0.38rem;
    padding: 0.34rem 0.82rem;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    border: 1px solid rgba(67, 56, 202, 0.22);
    color: #312e81;
    background: linear-gradient(180deg, #faf5ff 0%, #ede9fe 100%);
    box-shadow: none;
    transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.mode-pill::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #7c3aed;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}

.mode-pill[data-mode="chat"] {
    border-color: rgba(5, 150, 105, 0.22);
    color: #065f46;
    background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
    box-shadow: none;
}

.mode-pill[data-mode="chat"]::before {
    background: #059669;
    box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.12);
}

.input-wrapper .input-box {
    flex: 1;
    min-width: 0;
}

.input-buttons {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-disclaimer {
    max-width: 800px;
    margin: 0.5rem auto 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.phase-indicator {
    display: inline-block;
    margin-left: 0.6rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.12);
    color: #0f766e;
    border: 1px solid rgba(15, 118, 110, 0.32);
    font-style: normal;
    font-weight: 600;
}

.input-box {
    width: 100%;
    padding: 1rem 9.25rem 1rem 1rem;
    background: #ffffff;
    border: 1px solid #cbd5e0;
    border-radius: 12px;
    color: #2d3748;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.input-box::placeholder {
    color: #a0aec0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.input-box:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.roleplay-typing-indicator {
    position: absolute;
    right: 9rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.16);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.08);
    pointer-events: none;
    z-index: 1;
}

.roleplay-typing-indicator.is-visible {
    display: flex;
}

.roleplay-typing-indicator .loading-dot {
    width: 6px;
    height: 6px;
    background: #6366f1;
    border-radius: 50%;
    animation: bounce 1.8s infinite ease-in-out both;
    opacity: 0.9;
}

.roleplay-typing-indicator .loading-dot:nth-child(1) {
    animation-delay: -0.36s;
}

.roleplay-typing-indicator .loading-dot:nth-child(2) {
    animation-delay: -0.18s;
}

@media (max-width: 768px) {
    .input-box {
        font-size: 14px;
    }



    .input-disclaimer {
        flex-wrap: wrap;
        justify-content: center;
    }

    .roleplay-typing-indicator {
        right: 8rem;
    }
    
    .input-box::placeholder {
        font-size: 14px;
    }
}

/*
----------------------------------------------------
 Voice & Send Buttons
----------------------------------------------------
*/
.voice-button {
    width: 32px;
    height: 32px;
    background: #10b981;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.voice-button:hover:not(:disabled) {
    background: #059669;
    transform: scale(1.05);
}

.voice-button:active:not(:disabled) {
    transform: scale(0.95);
    background: #ef4444;
}

.voice-button.recording {
    background: #ef4444 !important;
    animation: pulse 1.5s ease-in-out infinite;
}

.voice-button.recording:hover {
    background: #dc2626 !important;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.voice-button:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

.voice-button svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.send-button {
    width: 32px;
    height: 32px;
    background: #6366f1;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: #4f46e5;
    transform: scale(1.05);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95);
}

.send-button:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

.send-button svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.send-button i {
    color: white !important;
    font-size: 16px;
}

.role-agent-button {
    background: #f59e0b;
    position: relative;
}

.role-agent-button:hover:not(:disabled) {
    background: #d97706;
}

.role-agent-button:disabled {
    background: #fcd34d;
}

.send-button[data-tooltip]::after,
.voice-button[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px);
    transform: translateX(-50%) translateY(6px);
    background: rgba(15, 23, 42, 0.96);
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.25;
    padding: 0.55rem 0.7rem;
    border-radius: 0.6rem;
    width: max-content;
    max-width: 220px;
    white-space: normal;
    text-align: center;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 20;
}

.send-button[data-tooltip]:hover::after,
.send-button[data-tooltip]:focus-visible::after,
.voice-button[data-tooltip]:hover::after,
.voice-button[data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.auto-interview-button {
    background: #0f766e;
}

.auto-interview-button:hover:not(:disabled) {
    background: #0d9488;
}

.auto-interview-button:disabled {
    background: #5eead4;
}

.auto-interview-button.is-active {
    background: #dc2626;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.18);
}

.auto-interview-button.is-active:hover:not(:disabled) {
    background: #b91c1c;
}

/*
----------------------------------------------------
 TTS (Text-to-Speech) Toggle Button
----------------------------------------------------
*/
.tts-toggle {
    width: 28px;
    height: 28px;
    background: #e2e8f0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    padding: 0;
    flex-shrink: 0;
}

.tts-toggle:hover {
    background: #cbd5e0;
    transform: scale(1.1);
}

.tts-toggle.active {
    background: #6366f1;
}

.tts-toggle.active svg {
    fill: white;
}

.tts-toggle svg {
    width: 14px;
    height: 14px;
    fill: #4a5568;
}

.tts-toggle.speaking {
    animation: tts-pulse 1s ease-in-out infinite;
}

@keyframes tts-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
}

.spinner-border {
    display: inline-block;
    width: 14px;
    height: 14px;
    vertical-align: middle;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tts-spin 0.75s linear infinite;
}

.spinner-border-sm {
    width: 12px;
    height: 12px;
    border-width: 2px;
}

@keyframes tts-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading {
    display: flex !important;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-start;
    padding: 0.5rem 0;
}

.loading-dot {
    width: 10px;
    height: 10px;
    background: #6366f1;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
    display: inline-block;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.stream-interrupted-toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%) translateY(8px);
    max-width: min(88vw, 320px);
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(28, 35, 47, 0.9);
    color: #f7f8fa;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
    opacity: 0;
    pointer-events: none;
    z-index: 1400;
    transition: opacity 160ms ease, transform 160ms ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.stream-interrupted-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/*
----------------------------------------------------
 Empty State & Suggestions
----------------------------------------------------
*/
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 1rem;
}

.empty-state-icon {
    font-size: 4rem;
}

@media (max-width: 768px) {
    .empty-state-icon {
        font-size: 3rem;
    }
}

.profile-photo {
    width: min(240px, 45vw);
    height: min(240px, 45vw);
    max-width: 30vh;
    max-height: 30vh;
    border-radius: 50%;
    object-fit: contain;
    padding: 18px;
    background: #fff;
    border: 4px solid #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

@media (max-width: 768px) {
    .profile-photo {
        width: min(180px, 52.5vw);
        height: min(180px, 52.5vw);
        max-width: 24vh;
        max-height: 24vh;
        border-width: 3px;
        padding: 14px;
    }
}

.empty-state h2 {
    font-size: 2rem;
    font-weight: 600;
    color: #1a202c;
    text-align: center;
}

.empty-state .intro-title-version {
    margin: 0.15rem 0 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #4a5568;
}

@media (max-width: 768px) {
    .empty-state h2 {
        font-size: 1.5rem;
    }

    .empty-state .intro-title-version {
        font-size: 0.95rem;
    }
}

.empty-state p {
    text-align: center;
    max-width: 800px;
}

.intro-ema-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.75rem;
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 2px solid rgba(37, 99, 235, 0.28);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.intro-ema-link:hover,
.intro-ema-link:focus-visible {
    color: #0f766e;
    border-color: rgba(15, 118, 110, 0.45);
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    max-width: 900px;
    margin: 2rem auto 0;
    width: 100%;
    justify-content: center;
}

@media (max-width: 768px) {
    .suggestions {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .suggestions {
        grid-template-columns: repeat(2, 1fr);
    }
}

.suggestion-card {
    padding: 1.25rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.suggestion-card:hover {
    background: #f8fafc;
    border-color: #6366f1;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.suggestion-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1a202c;
}

.suggestion-card p {
    font-size: 0.875rem;
    color: #718096;
    line-height: 1.5;
}

/* Agent-specific card styling */
.suggestion-card.agent-card[data-agent="translator"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
}

.suggestion-card.agent-card[data-agent="translator"]:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8a 100%);
    border-color: #5568d3;
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.3);
}

.suggestion-card.agent-card[data-agent="translator"] h3,
.suggestion-card.agent-card[data-agent="translator"] p {
    color: #ffffff;
}

.suggestion-card.agent-card[data-agent="dok2u"] {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #10b981;
}

.suggestion-card.agent-card[data-agent="dok2u"]:hover {
    background: linear-gradient(135deg, #0d9668 0%, #047857 100%);
    border-color: #0d9668;
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.3);
}

.suggestion-card.agent-card[data-agent="dok2u"] h3,
.suggestion-card.agent-card[data-agent="dok2u"] p {
    color: #ffffff;
}

/*
----------------------------------------------------
 Cookie Banner
----------------------------------------------------
*/
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    padding: 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.cookie-banner.show {
    transform: translateY(0);
}

.cookie-content {
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.cookie-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: #1a202c;
}

.cookie-content p {
    margin: 0 0 1rem 0;
    color: #4a5568;
    font-size: 0.95rem;
    line-height: 1.5;
}

.cookie-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.cookie-btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cookie-accept {
    background: #6366f1;
    color: white;
}

.cookie-accept:hover {
    background: #4f46e5;
    transform: translateY(-2px);
}

.cookie-decline {
    background: #e2e8f0;
    color: #4a5568;
}

.cookie-decline:hover {
    background: #cbd5e0;
}

@media (max-width: 768px) {
    .cookie-banner {
        padding: 1rem;
    }
    
    .cookie-content h3 {
        font-size: 1.1rem;
    }
    
    .cookie-content p {
        font-size: 0.9rem;
    }
    
    .cookie-buttons {
        flex-direction: column;
    }
    
    .cookie-btn {
        width: 100%;
        padding: 0.875rem;
    }
}

/*
----------------------------------------------------
 Mobile Keyboard State
----------------------------------------------------
Styles when mobile keyboard is visible
*/

body.keyboard-visible {
    /* Prevent body scroll when keyboard is shown */
    overflow: hidden;
}

body.keyboard-visible #chat-container {
    /* Adjust chat container when keyboard appears */
    padding-bottom: 0;
}

body.keyboard-visible .input-area {
    /* Ensure input stays visible above keyboard */
    position: sticky;
    bottom: 0;
    z-index: 100;
}

@media (max-width: 768px) {
    body.keyboard-visible .content {
        /* Adjust content height for mobile keyboard */
        max-height: calc(100vh - env(safe-area-inset-bottom));
    }
    
    body.keyboard-visible #chat-container {
        /* Reduce padding when keyboard is visible */
        padding: 1rem;
        padding-bottom: 0;
    }
}

/*
----------------------------------------------------
 Action Buttons
----------------------------------------------------
*/

.action-btn {
    border-radius: 999px;
    padding: 8px 12px;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
    cursor: pointer;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.message-actions {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    text-align: center;
}

.message-tts-row {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

@media (max-width: 768px) {
    .message-icon-column {
        display: inline-flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        width: auto;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .message-icon-column .message-icon,
    .message-icon-column .message-tts-row {
        flex: 0 0 auto;
    }

    .message-icon-column .message-tts-row {
        width: auto;
        margin-bottom: 0;
    }
}



.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.action-btn i {
    font-size: 1.3em;
}

.copy-btn{
    background: #f3f3f3;
}

.like-btn {
    background: #e6f9e6;
}

.dislike-btn {
    background: #f9e6e6;
}

.tts-btn {
    background: #6366f1;
    color: #fff;
    width: 41px;
    height: 41px;
    padding: 0;
    flex: 0 0 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    text-align: center;
    position: relative;
}

.tts-btn.is-playing {
    background: #e67575;
    color: #fff;
}

.tts-btn:hover {
    filter: brightness(1.05);
}

.tts-btn > * {
    margin: 0;
    line-height: 1;
    vertical-align: middle;
}

.tts-btn i,
.tts-btn .tts-ema-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
}

.tts-btn .spinner-border {
    width: 12px;
    height: 12px;
    border-width: 2px;
    margin: 0;
}

.tts-ema-mark {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
}

.tts-mini-speaker {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
    color: #4f46e5;
    opacity: 1;
    pointer-events: none;
}

.tts-mini-speaker i {
    font-size: 8px;
    line-height: 1;
}

/* Text action buttons (plan/recap/save) should not use the 40x40 circular icon style. */
.save-profile-btn,
.plan-confirm-btn,
.plan-adjust-btn,
.recap-accurate-btn,
.recap-add-btn {
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 34px;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    margin-right: 3px;
    margin-left: 3px;
    margin-top: 10px;
}

.save-profile-btn {
    background: #e6f4ea;
}

.plan-confirm-btn,
.recap-accurate-btn {
    background: #e6f0ff;
}

.plan-adjust-btn,
.recap-add-btn {
    background: #fff4e5;
}

.recap-accurate-btn,
.recap-add-btn {
    width: 240px;
    flex: 0 0 240px;
    justify-content: center;
    margin-top: 14px;
}

.plan-confirm-btn,
.plan-adjust-btn {
    width: 240px;
    flex: 0 0 240px;
    justify-content: center;
    margin-top: 14px;
}

