/* ===== CHAT CONTAINER ===== */
.chat-container {
    display: flex;
    height: calc(100vh - 100px);
    width: 100%;
    max-width: 100%;
    margin: 0;
    background-color: white;
}

/* ===== LEFT COLUMN - SESSIONS ===== */
.sessions-sidebar {
    width: 25%;
    background-color: #f1f3f6;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}

.sessions-header {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background-color: #f1f3f6;
    z-index: 10;
}

.sessions-header h2 {
    font-size: 1.1rem;
    color: #2c3e50;
}

.new-session-button {
    background-color: #3498db;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.new-session-button:hover {
    background-color: #2980b9;
    transform: scale(1.05);
}

.sessions-list {
    padding: 0.5rem;
    overflow-y: auto;
    flex: 1;
}

.session-item {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.session-item:hover {
    background-color: #e6f2ff;
    border-color: #3498db;
}

.session-item.active {
    background-color: #e6f2ff;
    border-color: #3498db;
    box-shadow: 0 2px 6px rgba(52,152,219,0.2);
}

.session-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-width: 0;
    gap: 8px;
}

.session-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.session-title {
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.session-date {
    font-size: 0.75rem;
    color: #7f8c8d;
    font-family: 'SFMono-Regular', Consolas, monospace;
}

.delete-session-button {
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem;
    margin-left: 4px;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-session-button:hover {
    color: #e74c3c;
}

.session-status-icon {
    display: inline-block;
    width: 1.2em;
    text-align: center;
    font-size: 1.1rem;
    line-height: 1;
    margin-right: 4px;
    vertical-align: middle;
    flex-shrink: 0;
}

.session-status-icon.blink {
    animation: blink-animation 1.5s infinite;
}

@keyframes blink-animation {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.session-status-icon.error {
    color: #e74c3c;
}

.session-status-icon.processing {
    color: #f39c12;
}

.session-status-icon.queued {
    color: #95a5a6;
}

.session-status-icon.unread {
    color: #3498db;
}

/* TTS icon in session list */
.session-status-icon.tts.playing {
    background-color: #e74c3c;
    color: white;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
    width: 1.2em;
    height: 1.2em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-right: 2px;
}

/* ===== RIGHT PART - MESSAGES ===== */
.chat-main {
    width: 75%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    height: 100%;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    margin-top: -0.7rem;  /* Align with sessions header (0.8rem padding top of .sessions-header minus extra .chat-main padding) */
    margin-bottom: 1rem;
}

.chat-header h2 {
    color: #2c3e50;
    margin: 0;
    font-size: 1.2rem;
}

.context-info-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.context-info {
    font-size: 0.9rem;
    color: #666;
    background-color: #f5f5f5;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
}

.save-chat-button,
.clear-context-button {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.save-chat-button:hover,
.clear-context-button:hover {
    background-color: #f0f0f0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 1rem;
    background-color: white;
}

/* ===== MESSAGES ===== */
.user-message,
.assistant-message,
.bot-message {
    max-width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    position: relative;
    animation: fadeIn 0.2s ease;
    margin-bottom: 0.8rem;
    display: flex;
    flex-direction: column;
    word-wrap: break-word;
}

.user-message {
    align-self: flex-start;
    background-color: #e6f2ff;
    border: 1px solid #bcd5f0;
}

.assistant-message,
.bot-message {
    align-self: flex-start;
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
}

.message-header {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-bottom: 0.5rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.message-content {
    line-height: 1.7;
    position: relative;
}

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

.text-muted {
    color: #7f8c8d !important;
}

.file-info {
    display: inline !important;
    color: #2c3e50 !important;
    font-size: 0.75rem !important;
    font-family: monospace !important;
    background-color: #f0f0f0 !important;
    padding: 2px 6px !important;
    border-radius: 12px !important;
    margin-left: 4px !important;
    white-space: nowrap !important;
    border: 1px solid #ddd !important;
    vertical-align: middle;
}

.image-container {
    position: relative;
    display: inline-block;
    margin-top: 10px;
    max-width: 100%;
}

.attached-image {
    max-width: 100%;
    max-height: 512px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: opacity 0.3s;
    display: block;
}

.attached-image:hover {
    opacity: 0.95;
}

.attached-file {
    margin-top: 10px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
}

.attached-file a {
    color: #3498db;
    text-decoration: none;
}

.attached-file a:hover {
    text-decoration: underline;
}

audio {
    width: 100%;
    margin-top: 10px;
    align-self: flex-start;
}

/* ===== TTS BUTTON ===== */
.tts-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background-color 0.2s;
    vertical-align: middle;
    line-height: 1;
}

.tts-button:hover {
    background-color: rgba(52, 73, 94, 0.1);
}

.tts-button:active {
    background-color: rgba(52, 73, 94, 0.2);
}

.tts-button.playing {
    background-color: #e74c3c !important;
    color: white !important;
    animation: pulse 1.5s infinite;
}

/* ===== COPY MESSAGE BUTTON ===== */
.copy-message-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background-color 0.2s;
    vertical-align: middle;
    line-height: 1;
}

.copy-message-button:hover {
    background-color: rgba(52, 73, 94, 0.1);
}

.copy-message-button:active {
    background-color: rgba(52, 73, 94, 0.2);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ===== INPUT FIELD AND BUTTONS ===== */
#file-preview-container {
    display: none;
    margin: 10px 0;
}

#file-preview-container div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f5f5f5;
    padding: 8px;
    border-radius: 8px;
}

#file-preview-name {
    font-size: 0.9rem;
    color: #2c3e50;
    font-weight: 500;
}

#file-preview-size {
    font-size: 0.8rem;
    color: #666;
    margin-left: 5px;
}

#remove-file-button {
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#remove-file-button:hover {
    background-color: #c0392b;
}

.message-input {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.message-input input[type="text"] {
    flex: 1;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

.message-input input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.message-input button {
    padding: 0.8rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: #f1f1f1;
    transition: background-color 0.3s;
}

#send-button {
    background-color: #3498db;
    color: white;
    min-width: 100px;
}

#send-button:hover {
    background-color: #2980b9;
}

#send-button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

/* Recording mode styles - transparent background, red text */
#send-button.recording-mode {
    background-color: transparent !important;
    color: #e74c3c !important;
    animation: pulse 1.5s infinite;
}

#send-button.recording-mode:hover {
    background-color: transparent !important;
    color: #c0392b !important;
}

#attach-file-button {
    background-color: #f1f1f1;
    color: #333;
}

#attach-file-button:hover {
    background-color: #e0e0e0;
}

.voice-record-button {
    background-color: #f1f1f1;
    color: #333;
    border: none;
    border-radius: 8px;
    padding: 0.8rem;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background-color 0.3s;
}

.voice-record-button:hover {
    background-color: #e0e0e0;
}

.voice-record-button.recording {
    background-color: #e74c3c !important;
    color: white !important;
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

/* ===== COPY BUTTONS ===== */
.code-block-wrapper {
    position: relative;
    margin: 1em 0;
}

.copy-code-button,
.copy-transcript-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(52,73,94,0.8);
    color: white;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    backdrop-filter: blur(2px);
}

.copy-code-button:hover,
.copy-transcript-button:hover {
    opacity: 1;
    background-color: #3498db;
    transform: scale(1.05);
}

.copy-code-button.copied,
.copy-transcript-button.copied {
    background-color: #27ae60;
    opacity: 1;
}

/* ===== MEDIA QUERIES FOR CHAT ===== */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: auto;
    }
    .sessions-sidebar {
        width: 100%;
        height: 250px;
    }
    .chat-main {
        width: 100%;
        padding: 10px;
    }
    .image-container {
        width: 100% !important;
    }
    .attached-image {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }
    .message-input {
        flex-wrap: wrap;
    }
    .message-input input[type="text"] {
        width: 100%;
    }
    .copy-code-button,
    .copy-transcript-button {
        width: 28px;
        height: 28px;
        font-size: 14px;
        top: 4px;
        right: 4px;
    }
    .session-status-icon {
        font-size: 1rem;
        width: 1.1em;
    }
}

/* ===== DARK THEME SUPPORT ===== */
.dark-theme .voice-record-button.recording {
    background-color: #e74c3c !important;
    color: white !important;
}

.dark-theme #send-button.recording-mode {
    background-color: transparent !important;
    color: #e74c3c !important;
}

.dark-theme #send-button.recording-mode:hover {
    color: #c0392b !important;
}

/* ===== RECORDING TIMER INSIDE SEND BUTTON ===== */
#send-button.recording-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    padding: 0.4rem 0.8rem;
}

#send-button.recording-mode .record-timer {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 2px;
}