/* universal_assistant_main_02.css */
/* Vista full-window con tab Chat/Videocall */
/* Pensata per finestra browser separata (window.open) a meta' schermo */


/* ============================= */
/* 1. VARIABILI CSS             */
/* ============================= */
:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --danger-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --border-color: #dee2e6;
    --text-muted: #6c757d;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    --orange-primary: #ff9900;
    --orange-hover: #e68a00;
    --header-height: 44px;
    --tabbar-height: 38px;
}

/* ============================= */
/* 2. RESET E BASE              */
/* ============================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    overflow: hidden;
}

/* ============================= */
/* 3. LAYOUT PRINCIPALE         */
/* ============================= */
.main-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============================= */
/* 4. HEADER COMPATTO            */
/* ============================= */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
    padding: 0 12px;
    background: var(--header-bg-color, #2b468d);
    color: white;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.header-agent-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    object-fit: cover;
    flex-shrink: 0;
}

.header-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.header-subtitle {
    font-size: 0.7rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.header-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 13px;
}

.header-btn:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* Nascondi hamburger/search/export quando NON in tab chat */
.header-btn.chat-only { display: none; }
body.tab-chat-active .header-btn.chat-only { display: flex; }

/* ============================= */
/* 5. TAB BAR                    */
/* ============================= */
.tab-bar {
    display: flex;
    height: var(--tabbar-height);
    border-bottom: 1px solid var(--border-color);
    background: var(--light-color);
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0 12px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    position: relative;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--header-bg-color, #2b468d);
    background: rgba(0,0,0,0.03);
}

.tab-btn.active {
    color: var(--header-bg-color, #2b468d);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 3px;
    background: var(--orange-primary);
    border-radius: 3px 3px 0 0;
}

.tab-btn i { font-size: 0.8rem; }

/* ============================= */
/* 6. TAB CONTENT                */
/* ============================= */
.tab-content {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Quando avatar attivo, tab nascosta usa visibility per mantenere stream */
.tab-content.keep-alive {
    display: flex !important;
    visibility: hidden;
    height: 0 !important;
    overflow: hidden;
    position: absolute;
    pointer-events: none;
}

/* ============================= */
/* 7. CHAT CONTAINER             */
/* ============================= */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

/* Conversation Info Card */
.conversation-info-card {
    background: var(--light-color);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: relative;
    z-index: 10;
}

.conversation-info-trigger {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 40px;
    z-index: 9;
    pointer-events: none;
}

.conversation-info-card.hover-mode + .chat-messages .conversation-info-trigger,
.conversation-info-trigger.active { pointer-events: auto; }

.conversation-info-card.hover-mode {
    transform: translateY(-100%);
    opacity: 0;
    position: absolute;
    top: 0; width: 100%; z-index: 20;
}

.conversation-info-card.hover-mode:hover,
.conversation-info-trigger:hover + .conversation-info-card.hover-mode,
.conversation-info-card.hover-mode.visible {
    transform: translateY(0);
    opacity: 1;
}

.card-lock-toggle {
    position: absolute;
    right: 8px; top: 50%;
    transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    padding: 3px 6px;
    border: 2px solid var(--orange-primary);
    border-radius: 6px;
    background-color: var(--orange-primary);
    transition: all 0.3s ease;
    z-index: 5;
}

.card-lock-toggle:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 2px 8px rgba(255, 153, 0, 0.4);
}

.card-lock-icon {
    width: 14px; height: 14px;
    transition: all 0.3s ease;
    filter: brightness(0) invert(1);
}

.card-lock-icon.unlocked { transform: scale(1.1); }

.conversation-info-content { max-width: 100%; }

.conversation-info-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.conversation-title-input {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    background: transparent;
    padding: 2px 4px;
    border-radius: 4px;
    color: #2b468d;
    min-width: 0;
}

.conversation-title-input:not([readonly]) {
    background: white;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.conversation-info-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Card Controls */
.card-controls {
    position: absolute;
    right: 8px; top: 50%;
    transform: translateY(-50%);
    display: flex; align-items: center; gap: 4px;
    z-index: 5;
}

.card-controls .card-lock-toggle {
    position: static;
    transform: none;
    width: 24px; height: 24px; padding: 3px;
}

.btn-toggle-all {
    width: 24px; height: 24px;
    border: 2px solid var(--orange-primary);
    border-radius: 4px;
    background-color: var(--orange-primary);
    color: white;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s ease;
}

.btn-toggle-all:hover {
    background-color: var(--orange-hover);
    border-color: var(--orange-hover);
    transform: scale(1.1);
}

.btn-toggle-all i { font-size: 11px; transition: transform 0.3s ease; }
.btn-toggle-all.expanded i { transform: rotate(180deg); }

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    min-height: 0;
}

.messages-wrapper { max-width: 100%; }

/* Welcome */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem 1rem;
    min-height: 200px;
    justify-content: center;
}

.welcome-avatar {
    width: 64px; height: 64px;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #f0f0f0;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.welcome-avatar img { width: 100%; height: 100%; object-fit: contain; }

.welcome-content h3 { font-size: 1.1rem; color: #2b468d; margin-bottom: 0.5rem; }
.welcome-content p { font-size: 0.88rem; color: #333; max-width: 400px; margin: 0 auto 0.5rem; line-height: 1.5; }
.welcome-hint { font-size: 0.78rem; color: var(--text-muted); font-style: italic; }

/* Messages */
.message {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    animation: fadeIn 0.3s ease;
}

.message.user { flex-direction: row-reverse; }

.message-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; overflow: hidden; font-size: 0.7rem;
}

.message.user .message-avatar { background: var(--primary-color); color: white; }
.message.assistant .message-avatar { background: #f0f0f0; padding: 2px; }
.message.assistant .message-avatar img { width: 100%; height: 100%; object-fit: contain; }

.message-content { max-width: 80%; }

.message-text {
    background: #f1f3f5;
    padding: 8px 10px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 0.84rem;
}

.message.user .message-text { background: var(--header-bg-color); color: white; }

.message-time { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; padding: 0 4px; }
.message.user .message-time { text-align: right; }

/* Message Formatting */
.message-text p { margin: 0 0 0.4rem 0; }
.message-text p:last-child { margin-bottom: 0; }
.message-text strong, .message-text b { font-weight: 600; }
.message-text code { background: #f4f4f4; padding: 1px 3px; border-radius: 3px; font-family: 'Courier New', monospace; font-size: 0.85em; }
.message-text pre { background: #f4f4f4; padding: 8px; border-radius: 4px; overflow-x: auto; margin: 0.4rem 0; }
.message-text ul, .message-text ol { margin: 0.4rem 0; padding-left: 1.25rem; }
.message-text li { margin: 0.2rem 0; }
.message-text blockquote { border-left: 3px solid #ddd; padding-left: 0.75rem; margin: 0.4rem 0; color: #666; }
.message-text h1, .message-text h2, .message-text h3, .message-text h4 { margin: 0.4rem 0; font-weight: 600; }
.message-text h1 { font-size: 1.2em; } .message-text h2 { font-size: 1.15em; }
.message-text h3 { font-size: 1.1em; } .message-text h4 { font-size: 1.05em; }
.message-text a { color: var(--primary-color); text-decoration: none; }
.message-text a:hover { text-decoration: underline; }
.message-text table { border-collapse: collapse; width: 100%; margin: 0.4rem 0; }
.message-text th, .message-text td { border: 1px solid #ddd; padding: 6px; text-align: left; font-size: 0.82rem; }
.message-text th { background: #f4f4f4; font-weight: 600; }

/* Message Footer */
.message-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 2px; padding: 0 4px;
}
.message.user .message-footer { flex-direction: row-reverse; }

.message-toggle-wrapper { display: flex; align-items: center; gap: 3px; }
.message.user .message-toggle-wrapper { flex-direction: row-reverse; }

.toggle-label { font-size: 0.65rem; color: var(--text-muted); cursor: pointer; transition: color 0.2s; }
.message-toggle-wrapper:hover .toggle-label { color: var(--orange-primary); }

.btn-toggle-message {
    width: 18px; height: 18px;
    border: none; border-radius: 50%;
    background: var(--orange-primary); color: white;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; padding: 0;
}
.btn-toggle-message:hover { background: var(--orange-hover); transform: scale(1.1); }
.btn-toggle-message i { font-size: 9px; transition: transform 0.3s ease; }

/* Collapsed */
.message.collapsed .message-text {
    max-height: 3.2em; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}
.message.collapsed .btn-toggle-message i { transform: rotate(180deg); }
.message .message-text { transition: max-height 0.3s ease; }
.message.collapsed { opacity: 0.85; }
.message.collapsed:hover { opacity: 1; }

/* Input Area */
.chat-input-area {
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
    background: white;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex; gap: 6px; align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    font-size: 0.84rem;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    min-height: 38px; max-height: 130px;
    overflow-y: auto;
    line-height: 1.4;
    font-family: inherit;
}

.message-input:focus { border-color: var(--primary-color); }

/* File Upload */
.file-preview-area {
    display: flex;
    gap: 8px;
    padding: 8px 10px 4px;
    overflow-x: auto;
    flex-wrap: nowrap;
}

.file-preview-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.72rem;
    white-space: nowrap;
    flex-shrink: 0;
    max-width: 180px;
    position: relative;
}

.file-preview-chip img.file-thumb {
    width: 36px; height: 36px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.file-preview-chip .file-icon {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: #e9ecef; border-radius: 4px;
    flex-shrink: 0; font-size: 1rem; color: var(--text-muted);
}

.file-preview-chip .file-icon.pdf { color: #dc3545; }
.file-preview-chip .file-icon.txt { color: #17a2b8; }

.file-preview-info {
    display: flex; flex-direction: column;
    min-width: 0; gap: 1px;
}

.file-preview-name {
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis;
    color: #333;
}

.file-preview-size { color: var(--text-muted); font-size: 0.65rem; }

.file-preview-remove {
    position: absolute; top: -4px; right: -4px;
    width: 16px; height: 16px;
    border-radius: 50%; background: var(--danger-color);
    color: white; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 8px; padding: 0;
    transition: transform 0.15s;
}
.file-preview-remove:hover { transform: scale(1.2); }

#fileUploadBtn { position: relative; }

.file-badge {
    position: absolute; top: -2px; right: -2px;
    width: 16px; height: 16px;
    background: var(--orange-primary); border-radius: 50%;
    font-size: 0.6rem; color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

.message-attachments {
    display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px;
}

.message-attachment-badge {
    display: inline-flex; align-items: center; gap: 3px;
    background: rgba(0,0,0,0.06); border-radius: 4px;
    padding: 2px 6px; font-size: 0.68rem; color: var(--text-muted);
}
.message-attachment-badge i { font-size: 0.6rem; }
.message.user .message-attachment-badge {
    background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.85);
}


/* ============================= */
/* 7b. INFO POPUP                */
/* ============================= */
.info-popup-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}

.info-popup {
    background: white; border-radius: 12px;
    max-width: 480px; width: 90%;
    max-height: 85vh; overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
    display: flex; flex-direction: column;
}

.info-popup-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--light-color);
}

.info-popup-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.95rem; color: var(--primary-color);
}

.info-popup-close {
    width: 28px; height: 28px;
    border: none; border-radius: 6px;
    background: transparent; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 14px;
    transition: all 0.15s;
}
.info-popup-close:hover { background: rgba(0,0,0,0.08); color: var(--danger-color); }

.info-popup-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.info-popup-body .info-modes {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; margin-bottom: 12px;
}

.info-popup-body .info-mode {
    background: #f8f9fa; border-radius: 8px; padding: 10px; text-align: center;
}
.info-popup-body .chat-mode { border-left: 3px solid #28a745; }
.info-popup-body .videocall-mode { border-left: 3px solid #fd7e14; }
.info-popup-body .mode-icon { font-size: 1.1rem; margin-bottom: 4px; }
.info-popup-body .chat-mode .mode-icon { color: #28a745; }
.info-popup-body .videocall-mode .mode-icon { color: #fd7e14; }
.info-popup-body .mode-title { font-weight: 600; font-size: 0.82rem; margin-bottom: 6px; }
.info-popup-body .mode-features { list-style: none; padding: 0; text-align: left; font-size: 0.75rem; }
.info-popup-body .mode-features li { display: flex; align-items: flex-start; gap: 5px; margin-bottom: 3px; color: #555; }
.info-popup-body .mode-features li i { font-size: 0.6rem; width: 10px; flex-shrink: 0; margin-top: 3px; }
.info-popup-body .chat-mode .mode-features li i { color: #28a745; }
.info-popup-body .videocall-mode .mode-features li i { color: #fd7e14; }

.info-popup-body .info-tips {
    background: #fff3cd; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px;
}
.info-popup-body .tip-item {
    display: flex; align-items: flex-start; gap: 6px; font-size: 0.75rem; color: #856404;
}
.info-popup-body .tip-item i { color: #fd7e14; flex-shrink: 0; margin-top: 2px; }

.info-popup-body .info-disclaimer {
    display: flex; align-items: flex-start; gap: 6px;
    background: #f8f9fa; border-radius: 6px; padding: 8px 10px;
    border-left: 3px solid #6c757d;
}
.info-popup-body .info-disclaimer i { color: #6c757d; flex-shrink: 0; margin-top: 2px; font-size: 0.72rem; }
.info-popup-body .info-disclaimer p { font-size: 0.72rem; color: #6c757d; margin: 0; line-height: 1.3; }

.info-popup-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--light-color);
}

.info-toggle-label {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer; font-size: 0.8rem; user-select: none;
}

.info-toggle-label input { display: none; }

.info-toggle-switch {
    position: relative;
    width: 36px; height: 20px;
    background: #ccc; border-radius: 10px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.info-toggle-switch::after {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px;
    background: white; border-radius: 50%;
    transition: transform 0.2s;
}
.info-toggle-label input:checked + .info-toggle-switch {
    background: var(--orange-primary);
}
.info-toggle-label input:checked + .info-toggle-switch::after {
    transform: translateX(16px);
}

.info-toggle-text {
    color: #333; font-weight: 500;
}


/* ============================= */
/* 8. AVATAR SECTION             */
/* ============================= */
.avatar-section {
    flex: 1;
    display: flex; flex-direction: column;
    background: #f8f9fa;
    padding: 12px;
    overflow-y: auto; overflow-x: hidden;
}

.avatar-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 10px;
    text-align: center;
    display: flex; flex-direction: column;
    flex-shrink: 0;
}

.avatar-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--light-color);
    text-align: left;
}

.avatar-header h3 { font-size: 0.88rem; font-weight: 600; margin: 0; color: #2b468d; }

.avatar-wrapper {
    position: relative; background: black;
    width: 100%; display: none;
}

.avatar-wrapper.active {
    display: block;
    padding-bottom: 56.25%; height: 0;
    position: relative;
    border-radius: 8px;
}

#avatarVideo, #heygenIframeContainer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    object-fit: contain;
}

#heygenIframe {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;
}

.avatar-controls {
    position: absolute; bottom: 8px; left: 8px; right: 8px;
    display: flex; justify-content: space-between; align-items: center;
}

.btn-start-call {
    display: block !important;
    margin: 10px auto;
    width: calc(100% - 24px); max-width: 300px;
    text-align: center; padding: 8px;
    font-size: 0.88rem;
    background: var(--orange-primary) !important;
    box-shadow: 0 4px 12px rgba(255, 153, 0, 0.3);
    border: none; font-weight: 500;
}

.btn-start-call:hover {
    transform: translateY(-2px);
    background: var(--orange-hover) !important;
}

.btn-start-call:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.avatar-container.active .btn-start-call { display: none !important; }
.btn-start-call i { margin-right: 6px; }

/* Connection Status */
.connection-status {
    display: flex; align-items: center; gap: 6px;
    background: rgba(0, 0, 0, 0.7);
    padding: 3px 8px; border-radius: 12px;
    font-size: 0.72rem; color: white;
}

.status-indicator { width: 7px; height: 7px; border-radius: 50%; background: #6c757d; }
.status-indicator.connected { background: #28a745; animation: pulse 2s infinite; }
.status-indicator.connecting { background: #ffc107; animation: pulse 1s infinite; }
.status-indicator.disconnected { background: #dc3545; }

/* Close Avatar Button */
.btn-close-avatar { background: transparent; color: var(--text-muted); width: 1.75rem; height: 1.75rem; display: none; }
.avatar-container.active .btn-close-avatar {
    display: flex !important;
    background: var(--orange-primary); color: white;
    width: 28px; height: 28px; border-radius: 50%; transition: all 0.3s;
}
.avatar-container.active .btn-close-avatar:hover { background: var(--orange-hover); transform: scale(1.1); }

/* Info Box Collapsible */
.info-box-details { flex-shrink: 0; }

.info-box-summary {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem; color: var(--primary-color); font-weight: 500;
    list-style: none;
}
.info-box-summary::-webkit-details-marker { display: none; }
.info-box-summary::before {
    content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
    font-size: 0.65rem; transition: transform 0.2s;
}
.info-box-details[open] .info-box-summary::before { transform: rotate(180deg); }
.info-box-summary:hover { background: var(--light-color); }

.info-box {
    background: white;
    border: 1px solid var(--border-color); border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 10px;
}

.info-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.info-mode { background: #f8f9fa; border-radius: 6px; padding: 8px; text-align: center; }
.chat-mode { border-left: 3px solid #28a745; }
.videocall-mode { border-left: 3px solid #fd7e14; }
.mode-icon { font-size: 1rem; margin-bottom: 2px; }
.chat-mode .mode-icon { color: #28a745; }
.videocall-mode .mode-icon { color: #fd7e14; }
.mode-title { font-weight: 600; font-size: 0.78rem; margin-bottom: 4px; }
.mode-features { list-style: none; padding: 0; text-align: left; font-size: 0.72rem; }
.mode-features li { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 2px; color: #555; }
.mode-features li i { font-size: 0.6rem; width: 10px; flex-shrink: 0; margin-top: 3px; }
.chat-mode .mode-features li i { color: #28a745; }
.videocall-mode .mode-features li i { color: #fd7e14; }

.info-disclaimer {
    display: flex; align-items: flex-start; gap: 6px;
    background: #f8f9fa; border-radius: 4px;
    padding: 6px 8px; border-left: 3px solid #6c757d;
}
.info-disclaimer i { color: #6c757d; flex-shrink: 0; margin-top: 2px; font-size: 0.72rem; }
.info-disclaimer p { font-size: 0.72rem; color: #6c757d; margin: 0; line-height: 1.3; }


/* ============================= */
/* 9. UI COMPONENTS              */
/* ============================= */
.btn {
    padding: 6px 12px; border: none; border-radius: 6px;
    font-size: 0.84rem; cursor: pointer; transition: all 0.2s;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--text-muted); color: white; }
.btn-secondary:hover { background: #5a6268; }
.btn-danger { background: var(--danger-color); color: white; }
.btn-danger:hover { background: #c82333; }

.btn-icon {
    width: 32px; height: 32px; padding: 0;
    border: none; border-radius: 50%;
    background: transparent; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.btn-icon:hover { background: rgba(0,0,0,0.05); }
.btn-icon.btn-primary { background: var(--orange-primary); color: white; }
.btn-icon.btn-primary:hover { background: var(--orange-hover); }

.btn-close-sidebar, .btn-edit-title, .btn-edit-conversation-title {
    background: var(--orange-primary) !important; border: none; color: white !important;
    cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.btn-close-sidebar { width: 32px; height: 32px; }
.btn-edit-title, .btn-edit-conversation-title { width: 24px; height: 24px; opacity: 0; flex-shrink: 0; }
.conversation-item:hover .btn-edit-title { opacity: 1; }
.btn-close-sidebar:hover, .btn-edit-title:hover, .btn-edit-conversation-title:hover {
    background: var(--orange-hover) !important; transform: scale(1.1);
}
.btn-close-sidebar i, .btn-edit-title i, .btn-edit-conversation-title i { color: white !important; font-size: 11px; }


/* ============================= */
/* 10. SIDEBAR MENU              */
/* ============================= */
.sidebar-menu {
    position: fixed; left: -380px; top: 0;
    width: 380px; height: 100vh;
    background: white;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    transition: left 0.3s ease;
    z-index: 1000;
    display: flex; flex-direction: column;
}
.sidebar-menu.active { left: 0; }

.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: none; z-index: 999;
}
.sidebar-overlay.active { display: block; }

.sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem; border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.sidebar-title { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 1.1rem; }
.sidebar-actions { padding: 1rem; flex-shrink: 0; }
.btn-new-conversation { width: 100%; justify-content: center; background: var(--orange-primary) !important; border: none; }
.btn-new-conversation:hover { background: var(--orange-hover) !important; }
.sidebar-search { padding: 0 1rem; margin-bottom: 1rem; flex-shrink: 0; }
.search-conversations { width: 100%; padding: 0.5rem 1rem; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.875rem; }
.conversations-list { flex: 1; overflow-y: auto; padding: 0 1rem 1rem; min-height: 0; }
.conversations-section { margin-bottom: 1.5rem; }
.section-title { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: 500; }
.conversation-item {
    display: flex; justify-content: space-between; align-items: start;
    padding: 0.75rem; margin-bottom: 0.5rem; border-radius: 6px; cursor: pointer; transition: background 0.2s;
}
.conversation-item:hover { background: var(--light-color); }
.conversation-item.active { background: #e7f3ff; border-left: 3px solid var(--primary-color); }
.conversation-content { flex: 1; min-width: 0; }
.conversation-title-wrapper { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.conversation-date { display: none; }
.conversation-title { flex: 1; font-weight: 500; font-size: 0.875rem; border: none; background: transparent; padding: 0.25rem; border-radius: 4px; }
.conversation-title:not([readonly]) { background: white; border: 1px solid var(--primary-color); }
.conversation-preview { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-meta { display: flex; gap: 1rem; margin-top: 0.25rem; font-size: 0.75rem; color: var(--text-muted); }
.conversation-actions { display: none; }

/* No floating sidebar toggle - it's in the header */
.floating-sidebar-toggle { display: none; }


/* ============================= */
/* 11. OVERLAYS & MODALS         */
/* ============================= */
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); display: none;
    align-items: center; justify-content: center; z-index: 2500;
}
.loading-overlay.active { display: flex; }
.loading-content { background: white; padding: 1.5rem 2rem; border-radius: 8px; text-align: center; }
.loading-spinner { font-size: 2rem; color: var(--primary-color); margin-bottom: 0.75rem; }
.loading-spinner i { animation: spin 1s linear infinite; }
.loading-spinner .fa-video { animation: pulse 1.5s ease-in-out infinite; }
.loading-content p { font-size: 1rem; color: #333; margin: 0; }

.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.modal-content { background: white; border-radius: 8px; max-width: 420px; width: 90%; max-height: 70vh; overflow: hidden; box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; }
.modal-content.modal-compact { max-width: 360px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); }
.modal-header h2 { font-size: 1rem; font-weight: 600; }
.close-modal { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); padding: 0; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center; }
.close-modal:hover { color: var(--dark-color); }
.modal-body { padding: 1rem; max-height: 50vh; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 1px solid var(--border-color); }
.modal-footer .btn { min-width: 80px; }
#conversationModal .modal-content { animation: modalSlideIn 0.3s ease; }


/* ============================= */
/* 12. TYPING & VOICE & SEARCH  */
/* ============================= */
.typing-indicator { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: typing 1.4s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
.typing-content { display: flex; align-items: center; gap: 0.5rem; }
.typing-message { font-size: 0.82rem; color: var(--text-muted); font-style: italic; animation: fadeInOut 2s ease-in-out infinite; }

.voice-recording { display: flex; align-items: center; gap: 0.75rem; padding: 0.4rem 0; }
.recording-animation { display: flex; gap: 3px; }
.recording-animation span { width: 3px; height: 18px; background: var(--danger-color); border-radius: 2px; animation: soundWave 0.6s ease-in-out infinite; }
.recording-animation span:nth-child(2) { animation-delay: 0.1s; height: 26px; }
.recording-animation span:nth-child(3) { animation-delay: 0.2s; height: 22px; }
.recording-time { font-size: 0.82rem; font-weight: 500; color: var(--text-muted); }

.search-input { width: 100%; padding: 8px 10px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.84rem; margin-bottom: 0.75rem; }
.search-results { max-height: 300px; overflow-y: auto; }
.search-result { padding: 8px; border: 1px solid var(--border-color); border-radius: 6px; margin-bottom: 6px; cursor: pointer; transition: background 0.2s; }
.search-result:hover { background: var(--light-color); }
.result-type { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }
.result-text { margin: 3px 0; font-size: 0.82rem; }
.result-text mark { background: #ffeb3b; padding: 0 2px; }
.result-time { font-size: 0.65rem; color: var(--text-muted); }
.no-results { text-align: center; color: var(--text-muted); padding: 1.5rem; }

.export-options { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1rem; }

/* Toast */
.toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    background: var(--dark-color); color: white;
    padding: 0.75rem 1rem; border-radius: 6px;
    box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 0.5rem;
    z-index: 2100; animation: slideInRight 0.3s ease; font-size: 0.84rem;
}
.toast-error { background: var(--danger-color); }
.toast-success { background: var(--success-color); }
.toast-info { background: #17a2b8; }
.toast.fade-out { animation: slideOutRight 0.3s ease; }


/* ============================= */
/* 13. ANIMATIONS                */
/* ============================= */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(80px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(80px); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes pulse { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.2); opacity: 0.7; } 100% { transform: scale(1); opacity: 1; } }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.7; } 30% { transform: translateY(-8px); opacity: 1; } }
@keyframes soundWave { 0%, 100% { transform: scaleY(0.5); } 50% { transform: scaleY(1); } }
@keyframes fadeInOut { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(-20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }


/* ============================= */
/* 14. SCROLLBARS                */
/* ============================= */
.chat-messages::-webkit-scrollbar, .conversations-list::-webkit-scrollbar, .avatar-section::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track, .conversations-list::-webkit-scrollbar-track, .avatar-section::-webkit-scrollbar-track { background: #f1f1f1; }
.chat-messages::-webkit-scrollbar-thumb, .conversations-list::-webkit-scrollbar-thumb, .avatar-section::-webkit-scrollbar-thumb { background: #888; border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover, .conversations-list::-webkit-scrollbar-thumb:hover, .avatar-section::-webkit-scrollbar-thumb:hover { background: #555; }


/* ============================= */
/* 15. UTILITY                   */
/* ============================= */
.no-conversations { text-align: center; color: var(--text-muted); padding: 1rem; font-style: italic; }
.conversation-item[data-messages="0"] .conversation-preview { font-style: italic; opacity: 0.7; }
.conversation-item.empty-conversation { background: #fff3cd; border-left: 3px solid #ffc107; }
.voice-message .message-text { position: relative; padding-left: 30px; background: #e3f2fd; border: 1px solid #90caf9; }
.voice-indicator { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; color: var(--text-muted); }
.message.user.voice-message .message-text { background: #1565c0; border: 1px solid #0d47a1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
