/**
 * RE::DACT Chat Styles
 * 
 * This file contains:
 * - Chat container
 * - Mode tabs
 * - Chat messages (user/AI)
 * - Streaming/loading indicators
 * - Message actions
 * - Chat input
 * - Chat peek bar (mobile)
 * - Voice input button
 * - File upload button
 */

/* --- CHAT CONTAINER --- */
.chat {
    display: flex;
    flex-direction: column;
    height: 320px;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-secondary);
    flex-shrink: 0;
    position: relative;
}

.chat-resizer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
    background: transparent;
    z-index: 10;
}

/* --- MODE TABS --- */
.chat-tabs {
    display: flex;
    gap: 6px;
    padding: 6px 16px;
    background: var(--color-bg-primary);
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
}

.tab {
    padding: 4px 14px;
    background: transparent;
    border: none;
    border-radius: 99px;
    cursor: pointer;
    color: var(--color-text-tertiary);
    font-weight: 400;
    font-size: 11px;
}

.tab.active {
    background: var(--color-accent);
    color: white;
}

.tab.pro-only {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    font-weight: 600;
}

.tab.pro-only:hover {
    background: linear-gradient(135deg, #FFC700, #FF9500);
}

.tab.pro-only.active {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    box-shadow: 0 2px 8px rgba(255,165,0,0.4);
}

/* --- MODE HINTS --- */
.mode-hint {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    color: rgba(255,255,255,0.7);
    font-size: 8px;
    font-weight: 400;
    font-family: var(--font-sans);
    letter-spacing: 0.02em;
    z-index: 5;
    justify-content: flex-start;
    align-items: center;
    padding-left: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mode-hint.visible {
    opacity: 1;
}

.chat-peek-bar:has(.mode-hint.visible) .chat-peek-content {
    opacity: 0;
}

.mode-hint-desktop {
    margin-left: 12px;
    font-size: 11px;
    font-style: italic;
    color: var(--color-text-tertiary);
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.mode-hint-desktop.visible {
    opacity: 1;
}

/* --- CHAT MESSAGES --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Scroll anchoring - prevents content jumping during streaming */
.chat-messages * {
    overflow-anchor: none;
}

.chat-messages .scroll-anchor {
    overflow-anchor: auto;
    height: 1px;
}

/* Message bubbles */
.msg {
    max-width: 85%;
    padding: 8px 12px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    border-radius: 12px;
    font-size: 14px;
}

.msg p {
    margin: 0 0 0.8em 0;
    text-align: left;
}

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

.msg.user {
    align-self: flex-end;
    background: #000;
    color: #fff;
    border-bottom-right-radius: 4px;
    padding: 6px 12px;
}

.msg.user p {
    text-align: left;
    margin-bottom: 0;
}

.msg.ai {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--color-border-light);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* --- TYPEWRITER CURSOR --- */
.typewriter-content {
    display: inline;
}

.typewriter-cursor {
    display: inline;
    color: var(--color-accent);
    font-weight: 300;
    animation: cursorBlink 0.8s ease-in-out infinite;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.msg.ai.streaming .typewriter-cursor {
    animation: cursorBlink 0.5s ease-in-out infinite;
}

/* --- LOADING INDICATOR --- */
.msg.loading {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 8px 0;
    padding-left: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-secondary);
    font-size: 14px;
    border-radius: 0;
}

.msg.loading::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: conic-gradient(from 0deg, transparent 0%, var(--color-accent) 25%, transparent 50%);
    border-radius: 50%;
    animation: sunburstSpin 1s linear infinite;
}

.msg.loading::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: var(--color-bg-primary);
    border-radius: 50%;
}

@keyframes sunburstSpin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

.loading-text {
    color: var(--color-text-secondary);
}

/* --- MESSAGE ACTIONS --- */
.msg-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.msg:hover .msg-actions {
    opacity: 1;
}

.msg-action-btn {
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.msg-action-btn:hover {
    background: #fff;
}

.msg-action-btn svg {
    width: 14px;
    height: 14px;
}

.msg-action-btn.feedback-btn {
    color: var(--color-text-tertiary);
}

.msg-action-btn.feedback-btn:hover {
    color: var(--color-text-primary);
}

.msg-action-btn.feedback-btn.active-positive {
    color: #10b981;
    background: rgba(16,185,129,0.1);
    border-color: #10b981;
}

.msg-action-btn.feedback-btn.active-negative {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
    border-color: #ef4444;
}

.msg-action-btn.feedback-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.msg-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    opacity: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}

.msg:hover .msg-copy-btn {
    opacity: 1;
}

/* --- CHAT INPUT --- */
.chat-input {
    display: flex;
    gap: 12px;
    padding: 20px;
    background: var(--color-bg-primary);
    border-top: 1px solid var(--color-border-light);
}

.chat-input button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.chat-input-wrapper input {
    flex: 1;
    padding: 10px 44px 10px 16px;
    border: 1px solid var(--color-border);
    border-radius: 99px;
    outline: none;
    font-size: 14px;
    background: var(--color-bg-primary);
}

/* --- VOICE INPUT BUTTON --- */
.voice-input-btn { 
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%); 
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center; 
    background: transparent;
    border: none;
    border-radius: 50%; 
    cursor: pointer;
    color: var(--color-text-tertiary);
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
}

.voice-input-btn:active {
    background: rgba(0,0,0,0.05);
}

.voice-input-btn.recording {
    color: #DC2626;
    animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording { 
    0%, 100% { transform: translateY(-50%) scale(1); opacity: 1; } 
    50% { transform: translateY(-50%) scale(1.15); opacity: 0.8; } 
}

.voice-input-btn svg {
    width: 18px;
    height: 18px;
}

/* --- FILE UPLOAD BUTTON (RE::VIEW) --- */
.file-upload-btn { 
    position: absolute;
    right: 44px;
    top: 50%;
    transform: translateY(-50%); 
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center; 
    background: transparent;
    border: none;
    border-radius: 50%; 
    cursor: pointer;
    color: var(--color-text-tertiary);
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
}

.file-upload-btn:active {
    background: rgba(0,0,0,0.05);
}

.file-upload-btn.has-file {
    color: var(--color-accent);
}

.file-upload-btn svg {
    width: 18px;
    height: 18px;
}

/* --- CHAT PEEK BAR (Mobile) --- */
.chat-peek-bar {
    height: 52px;
    min-height: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    background: #000000 !important;
    color: #FFFFFF;
    transition: all 0.2s ease;
    z-index: 10;
    position: relative;
}

.chat-peek-bar:hover {
    background: #000000 !important;
}

.chat-peek-bar:active {
    transform: scale(0.98);
}

.chat-peek-content {
    color: white;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-peek-content::before {
    content: '';
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.chat.open .chat-peek-bar {
    height: 12px;
    min-height: 12px;
    background: #000000 !important;
}

.chat.open .chat-peek-content {
    display: none;
}

/* Source links in AI responses */
.source-link {
    color: var(--accent-color, #4da6ff);
    text-decoration: underline;
    text-decoration-color: rgba(77, 166, 255, 0.4);
    transition: all 0.2s ease;
}

.source-link:hover {
    color: var(--accent-hover, #7dbfff);
    text-decoration-color: var(--accent-hover, #7dbfff);
}

.source-link:visited {
    color: #9d7dff;
}

/* Sources section at bottom of response */
.chat-message hr {
    border: none;
    border-top: 1px solid var(--border-color, #333);
    margin: 1em 0;
}

