/**
 * Unified Chat Styles
 * Modern, responsive chat interface for all chat types
 */

/* ===== CHAT CONTAINER ===== */
.unified-chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    background: var(--bg-primary, #ffffff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ===== CHAT HEADER ===== */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-secondary, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    min-height: 60px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary, #64748b);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.status-indicator.online {
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.status-indicator.offline {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.chat-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.chat-actions {
    display: flex;
    gap: 8px;
}

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

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color, #e2e8f0);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary, #64748b);
}

/* ===== WELCOME MESSAGE ===== */
.welcome-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-content {
    max-width: 400px;
    padding: 40px 20px;
}

.welcome-content h4 {
    margin: 0 0 12px 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

.welcome-content p {
    margin: 0 0 24px 0;
    font-size: 16px;
    color: var(--text-secondary, #64748b);
    line-height: 1.5;
}

.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary, #f8fafc);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary, #64748b);
}

.feature i {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color, #6366f1);
    color: white;
    border-radius: 4px;
    font-size: 12px;
}

/* ===== MESSAGES ===== */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease-out;
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message.system {
    align-self: center;
    max-width: 90%;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-role {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-time {
    font-size: 11px;
    color: var(--text-tertiary, #94a3b8);
}

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user .message-content {
    background: var(--primary-color, #6366f1);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-primary, #1e293b);
    border: 1px solid var(--border-color, #e2e8f0);
    border-bottom-left-radius: 4px;
}

.message.system .message-content {
    background: var(--warning-bg, #fef3c7);
    color: var(--warning-text, #92400e);
    border: 1px solid var(--warning-border, #f59e0b);
    text-align: center;
    font-size: 13px;
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.tts-container {
    margin-top: 8px;
}

.tts-audio {
    width: 100%;
    max-width: 300px;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-secondary, #f8fafc);
    border-top: 1px solid var(--border-color, #e2e8f0);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary, #64748b);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-text {
    font-size: 14px;
    color: var(--text-secondary, #64748b);
    font-style: italic;
}

/* ===== CHAT INPUT ===== */
.chat-input-container {
    background: var(--bg-primary, #ffffff);
    border-top: 1px solid var(--border-color, #e2e8f0);
    padding: 16px 20px;
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

#message-input:focus {
    border-color: var(--primary-color, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#message-input::placeholder {
    color: var(--text-tertiary, #94a3b8);
}

#send-button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: var(--primary-color, #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#send-button:hover:not(:disabled) {
    background: var(--primary-hover, #5856eb);
    transform: translateY(-1px);
}

#send-button:disabled {
    background: var(--text-tertiary, #94a3b8);
    cursor: not-allowed;
    transform: none;
}

/* ===== INPUT FOOTER ===== */
.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.input-actions {
    display: flex;
    gap: 8px;
}

.input-info {
    font-size: 12px;
    color: var(--text-tertiary, #94a3b8);
}

.char-count.warning {
    color: var(--warning-text, #f59e0b);
    font-weight: 600;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #1e293b);
}

.btn:hover {
    background: var(--bg-secondary, #f8fafc);
    border-color: var(--text-secondary, #64748b);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--primary-color, #6366f1);
    border-color: var(--primary-color, #6366f1);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover, #5856eb);
    border-color: var(--primary-hover, #5856eb);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color, #e2e8f0);
    color: var(--text-secondary, #64748b);
}

.btn-outline:hover {
    background: var(--bg-secondary, #f8fafc);
    border-color: var(--text-secondary, #64748b);
    color: var(--text-primary, #1e293b);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.btn.active {
    background: var(--primary-color, #6366f1);
    border-color: var(--primary-color, #6366f1);
    color: white;
}

/* ===== ICONS ===== */
.icon-send::before { content: "→"; }
.icon-mic::before { content: "🎤"; }
.icon-stop::before { content: "⏹"; }
.icon-trash::before { content: "🗑"; }
.icon-zap::before { content: "⚡"; }
.icon-users::before { content: "👥"; }

/* ===== ANIMATIONS ===== */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .unified-chat-container {
        height: 100vh;
        border-radius: 0;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-input-container {
        padding: 12px 16px;
    }
    
    .input-group {
        gap: 8px;
    }
    
    #message-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .welcome-content {
        padding: 20px 16px;
    }
    
    .welcome-content h4 {
        font-size: 20px;
    }
    
    .welcome-features {
        gap: 8px;
    }
    
    .feature {
        padding: 8px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .connection-status {
        order: 2;
    }
    
    .chat-title {
        order: 1;
    }
    
    .chat-actions {
        order: 3;
        align-self: flex-end;
    }
    
    .message {
        max-width: 95%;
    }
    
    .input-footer {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}

/* ===== DARK MODE ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1e293b;
        --bg-secondary: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-tertiary: #94a3b8;
        --border-color: #475569;
        --primary-color: #6366f1;
        --primary-hover: #5856eb;
        --warning-bg: #451a03;
        --warning-text: #fbbf24;
        --warning-border: #f59e0b;
    }
    
    .unified-chat-container {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    
    .message.assistant .message-content {
        background: var(--bg-secondary, #334155);
        border-color: var(--border-color, #475569);
    }
    
    .message.system .message-content {
        background: var(--warning-bg, #451a03);
        border-color: var(--warning-border, #f59e0b);
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.btn:focus,
#message-input:focus {
    outline: 2px solid var(--primary-color, #6366f1);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .message.user .message-content {
        background: #000000;
        color: #ffffff;
        border: 2px solid #ffffff;
    }
    
    .message.assistant .message-content {
        background: #ffffff;
        color: #000000;
        border: 2px solid #000000;
    }
}
