﻿.chat-container {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 2000;
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Floating button */
.chat-button {
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    position: absolute;
    bottom: 20px;
    right: 20px;
}

/* Chat window */
.chat-window {
    position: absolute;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: default;
    resize: none;
    transition: box-shadow 0.2s ease-in-out;
    max-width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
}

    .chat-window:active {
        box-shadow: 0 6px 25px rgba(0,0,0,0.4);
    }

    .chat-window.maximized {
        position: fixed;
        width: calc(100vw - 20px) !important;
        height: calc(100dvh - 20px) !important;
        border-radius: 12px;
    }

    .chat-window.maximized .chat-header {
        cursor: default;
    }

    .chat-window.maximized .resize-handle {
        display: none;
    }

.chat-window.mobile-fullscreen {
    position: fixed;
    inset: 0;
    width: 100vw !important;
    height: 100dvh !important;
    border-radius: 0;
    box-shadow: 0 12px 35px rgba(15,23,42,0.18);
}

    .chat-window.mobile-fullscreen .chat-header {
        cursor: default;
    }

    .chat-window.mobile-fullscreen .resize-handle {
        display: none;
    }

/* Header */
.chat-header {
    background: var(--rz-primary);
    color: white;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    cursor: move;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.chat-header i,
.chat-header .rzi,
.chat-header .material-icons,
.chat-header-menu i,
.chat-header-menu .rzi,
.chat-header-menu .material-icons {
    color: #0f172a;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-toggles {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.chat-header-actions {
    margin-left: auto;
}

.chat-model-panel {
    padding: 10px 12px;
    background: #f0f4ff;
    border-bottom: 1px solid #d7e3ff;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.model-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.model-row label {
    font-weight: 600;
    min-width: 70px;
}

.model-select {
    background: white;
    color: #111;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 6px;
}

.model-cost {
    font-size: 0.9rem;
    color: #374151;
}

.chat-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: rgba(255,255,255,0.12);
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
}

.chat-toggle.active {
    background: rgba(255,255,255,0.24);
}

.chat-toggle i {
    color: white;
    font-size: 14px;
}

.chat-header-actions {
    display: flex;
    gap: 0.35rem;
}

.chat-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

/* Messages */
.chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    background: #f7f7f7;
    min-width: 0;
}

.chat-messages::-webkit-scrollbar,
.chat-history-list::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.chat-messages,
.chat-history-list {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.msg {
    margin: 5px 0;
    padding: 8px 10px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .msg.user {
        background-color: var(--rz-primary);
        color: white;
        margin-left: auto;
    }

    .msg.bot {
        background-color: #e0e0e0;
        color: black;
        margin-right: auto;
    }

    .msg.system {
        background-color: #fff6d9;
        color: #5f4b00;
        margin: auto;
        font-style: italic;
    }

.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    opacity: 0.9;
}

.msg-sender {
    letter-spacing: 0.01em;
}

.msg-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: normal;
    color: inherit;
}

.msg-paragraph {
    margin: 0 0 4px 0;
}

.msg-paragraph:last-child {
    margin-bottom: 0;
}

.msg-list {
    margin: 0 0 6px 18px;
    padding: 0;
}

.msg-list li {
    margin: 0 0 4px 0;
}

.msg-list li:last-child {
    margin-bottom: 0;
}

.msg-code {
    background: #111827;
    color: #e5e7eb;
    padding: 10px;
    border-radius: 8px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

.msg-code code {
    color: inherit;
}

.msg-empty {
    color: #6b7280;
    font-style: italic;
}

.thinking-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #6b7280;
    padding: 6px 2px;
    font-size: 0.95rem;
    width: 100%;
    box-sizing: border-box;
}

.thinking-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.thinking-text {
    color: inherit;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    display: inline-block;
    animation: pulse 1.2s ease-in-out infinite;
}

.answer-now-button {
    background: none;
    border: none;
    color: #4b5563;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}

.answer-now-button:hover {
    text-decoration: underline;
    color: #111827;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.chat-history-panel {
    width: 260px;
    background: #fff;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
}

.chat-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.history-entry {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0.5rem;
    text-align: left;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

    .history-entry.active {
        border-color: var(--rz-primary);
        background: #eef3ff;
    }

    .history-entry:hover {
        border-color: var(--rz-primary);
    }

/* Uploads */
.chat-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.chat-upload-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px;
}

.chat-upload-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: inset 0 1px 0 rgba(0,0,0,0.02);
}

.chat-upload-item.uploading {
    border-color: #bfdbfe;
}

.chat-upload-item.completed {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.chat-upload-item.failed {
    border-color: #fecdd3;
    background: #fff1f2;
}

.chat-upload-thumb img,
.chat-upload-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    object-fit: cover;
}

.chat-upload-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
    color: #0f172a;
    font-weight: 700;
}

.chat-upload-details {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.chat-upload-title {
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-upload-meta {
    font-size: 0.85rem;
    color: #475569;
}

.chat-upload-progress {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.chat-upload-progress-bar {
    height: 100%;
    width: 0;
    background: #2563eb;
    transition: width 0.2s ease;
}

.chat-upload-error {
    color: #b91c1c;
    font-size: 0.85rem;
}

.chat-upload-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 280px;
    max-height: 70%;
    overflow: auto;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 35px rgba(15,23,42,0.08);
    padding: 10px;
    z-index: 10;
}

.chat-upload-overlay-title {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 6px;
}

.large-upload-toggle.disabled .rz-button-icon {
    position: relative;
    color: #64748b;
}

.large-upload-toggle.disabled .rz-button-icon::after {
    content: "";
    position: absolute;
    left: -2px;
    right: -2px;
    top: 50%;
    border-top: 2px solid #dc2626;
    transform: rotate(-15deg);
}

.large-upload-toggle.active .rz-button-icon {
    color: #16a34a;
}

/* Input */
.chat-input {
    display: flex;
    align-items: center;
    padding: 8px;
    border-top: 1px solid #ddd;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-input .rz-textbox {
    flex: 1 1 180px;
    min-width: 0;
}

/* Resize handle */
.resize-handle {
    height: 10px;
    width: 100%;
    cursor: ns-resize;
    background: linear-gradient(to bottom, transparent, #ccc);
}

.chat-helper-text {
    padding: 8px 12px;
    color: #4b5563;
    font-size: 0.95rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.recording-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #fff1f2;
    border-top: 1px solid #fecdd3;
    gap: 0.75rem;
    width: 100%;
}

.recording-visual {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.recording-visual .bar {
    width: 5px;
    background: #e11d48;
    border-radius: 2px;
    animation: pulseBar 1.2s ease-in-out infinite;
}

.recording-visual .bar-1 { height: 12px; animation-delay: 0s; }
.recording-visual .bar-2 { height: 18px; animation-delay: 0.1s; }
.recording-visual .bar-3 { height: 24px; animation-delay: 0.2s; }
.recording-visual .bar-4 { height: 18px; animation-delay: 0.3s; }
.recording-visual .bar-5 { height: 14px; animation-delay: 0.4s; }

.recording-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.recording-text {
    color: #b91c1c;
    font-weight: 600;
}

@keyframes pulseBar {
    0% { transform: scaleY(0.8); opacity: 0.7; }
    50% { transform: scaleY(1.4); opacity: 1; }
    100% { transform: scaleY(0.8); opacity: 0.7; }
}

.recording-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    flex: 1 1 auto;
}

.model-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 2px 4px;
    margin: 6px 0 0;
    color: #4b5563;
    font-size: 0.85rem;
}

.recording-inline.full-width {
    justify-content: space-between;
}

.recording-inline.transcribing {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    padding: 8px 12px;
}

.recording-visual.inline {
    flex: 0 0 auto;
}

/* Responsive: mobile/tablet full screen */
@media (max-width: 1024px) {
    .chat-window,
    .chat-window.mobile-fullscreen {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0;
    }

    .chat-window.maximized {
        width: 100vw !important;
        height: 100dvh !important;
        border-radius: 0;
    }

    .chat-header {
        cursor: default;
        padding-top: calc(10px + env(safe-area-inset-top));
    }

    .chat-header-tabs {
        order: 3;
        width: 100%;
    }

    .chat-header-actions {
        margin-left: auto;
    }

    .resize-handle {
        display: none;
    }

    .chat-body {
        flex-direction: column;
    }

    .chat-history-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid #ddd;
    }

    .chat-input {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
}

.chat-tabs {
    display: flex;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

.chat-tab {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
}

.chat-tab.active {
    background: #dbeafe;
    border-color: #2563eb;
    color: #1e40af;
}

.team-chat-body {
    padding: 0;
    overflow: hidden;
}

.chat-header-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

.chat-header-menu-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: #0f172a;
}

.chat-header-menu .chat-toggle {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
}

.chat-header-menu .chat-toggle.active {
    background: #dbeafe;
    border-color: #2563eb;
    color: #1e40af;
}

.chat-header-menu .rz-button {
    color: #0f172a;
}

.chat-header-menu .rz-button .rzi,
.chat-header-menu .rz-button .rz-button-text {
    color: #0f172a;
}

@media (max-width: 768px) {
    .chat-header {
        gap: 0.5rem;
    }

    .chat-tab {
        flex: 1 1 auto;
        text-align: center;
    }

    .chat-header-menu-section {
        gap: 8px;
    }

    .chat-input .rz-textbox {
        flex-basis: 100%;
    }

    .chat-input .rz-button {
        min-height: 38px;
    }

    .model-pill {
        margin: 4px 8px 0;
    }
}
