/**
 * Market Briefing Assistant - CSS Styles
 * Dark theme UI for real-time stock voice assistant
 */

/* Container */
.market-briefing-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 450px;
    height: 600px;
    margin: 0 auto;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%);
    border-radius: 20px;
    overflow: hidden;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #ffffff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Background decoration */
.market-briefing-container::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -20%;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.market-briefing-container::after {
    content: '';
    position: absolute;
    bottom: -10%;
    right: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Header */
.mb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.mb-header-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mb-header-title h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mb-header-title h2 .icon-live {
    color: #ef4444;
    animation: pulse 2s infinite;
}

.mb-header-subtitle {
    font-size: 10px;
    color: #9ca3af;
    font-weight: 500;
}

.mb-header-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mb-connection-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    transition: all 0.3s ease;
}

.mb-connection-dot.connecting {
    background: #f59e0b;
    animation: pulse 1s infinite;
}

.mb-connection-dot.connected {
    background: #22c55e;
    animation: pulse 2s infinite;
}

/* Usage indicator */
.mb-usage-badge {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 11px;
    color: #9ca3af;
}

.mb-usage-badge.warning {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* Chat Area */
.mb-chat-area {
    flex: 1 1 auto;
    /* Allow grow and shrink, but prefer growing */
    overflow-y: auto;
    padding: 16px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    /* Prevent collapse */
}

/* ... scrollbar ... */
.mb-chat-area::-webkit-scrollbar {
    width: 4px;
}

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

.mb-chat-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Empty state */
.mb-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    opacity: 0.5;
}

.mb-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    position: relative;
}

.mb-empty-icon.connected::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.2);
    animation: ping 2s infinite;
}

.mb-empty-text {
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-line;
}

/* Messages */
.mb-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
    word-break: break-word;
    /* Ensure text wraps */
    min-height: 24px;
    /* Ensure bubble has height even if empty */
    display: flex;
    align-items: center;
}

.mb-message.user {
    align-self: flex-end;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #ffffff;
    /* Explicit white */
    border-bottom-right-radius: 4px;
}

.mb-message.model {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    /* Explicit white */
    border-bottom-left-radius: 4px;
}

.mb-message.streaming {
    /* No pulse - just subtle glow instead */
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.15);
}

.mb-message.model.streaming::after {
    content: '▌';
    display: inline;
    color: #ef4444;
    animation: blink 0.7s steps(1) infinite;
    font-weight: bold;
}

/* Sources */
.mb-sources {
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 10;
    overflow-x: auto;
    white-space: nowrap;
}

.mb-sources::-webkit-scrollbar {
    height: 3px;
}

.mb-sources-inner {
    display: flex;
    gap: 8px;
}

.mb-source-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    font-size: 10px;
    color: #d1d5db;
    text-decoration: none;
    transition: all 0.2s ease;
    max-width: 150px;
}

.mb-source-chip:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mb-source-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Visualizer */
.mb-visualizer-container {
    padding: 12px 16px;
    z-index: 10;
}

.mb-visualizer {
    width: 100%;
    height: 60px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

/* Controls */
.mb-controls {
    padding: 16px;
    background: rgba(10, 10, 10, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mb-control-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.mb-control-btn:active {
    transform: scale(0.98);
}

.mb-control-btn.start {
    background: #ffffff;
    color: #0a0a0a;
    box-shadow: 0 4px 14px rgba(255, 255, 255, 0.1);
}

.mb-control-btn.start:hover {
    background: #e5e7eb;
}

.mb-control-btn.stop {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.2);
}

.mb-control-btn.stop:hover {
    background: #dc2626;
}

.mb-control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mb-control-btn .spinner {
    animation: spin 1s linear infinite;
}

/* Error message */
.mb-error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: #fca5a5;
    text-align: center;
}

/* API Key Modal */
.mb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mb-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mb-modal {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.mb-modal-overlay.active .mb-modal {
    transform: scale(1);
}

.mb-modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.mb-modal-desc {
    font-size: 13px;
    color: #9ca3af;
    margin-bottom: 20px;
    line-height: 1.5;
}

.mb-modal-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #ffffff;
    font-size: 14px;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.2s ease;
}

.mb-modal-input:focus {
    border-color: #3b82f6;
}

.mb-modal-input::placeholder {
    color: #6b7280;
}

.mb-modal-buttons {
    display: flex;
    gap: 12px;
}

.mb-modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mb-modal-btn.primary {
    background: #3b82f6;
    color: #ffffff;
}

.mb-modal-btn.primary:hover {
    background: #2563eb;
}

.mb-modal-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
}

.mb-modal-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Link button */
.mb-api-key-link {
    font-size: 12px;
    color: #60a5fa;
    text-align: center;
    cursor: pointer;
    text-decoration: underline;
}

.mb-api-key-link:hover {
    color: #93c5fd;
}

/* Animations */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes ping {

    75%,
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Mode Selection */
.mb-mode-selection {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    justify-content: flex-start;
    background: rgba(10, 10, 10, 0.4);
    backdrop-filter: blur(10px);
    z-index: 20;
}

.mb-mode-title {
    font-size: 20px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 8px;
    background: linear-gradient(to right, #ffffff, #9ca3af);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mb-mode-desc {
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
    margin-bottom: 24px;
}

.mb-mode-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.mb-mode-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.mb-mode-card.quick:hover {
    border-color: rgba(59, 130, 246, 0.4);
}

.mb-mode-card.deep:hover {
    border-color: rgba(139, 92, 246, 0.4);
}

.mb-mode-card.deep-voice:hover {
    border-color: rgba(139, 92, 246, 0.4);
}

.mb-mode-card.deep-text:hover {
    border-color: rgba(34, 197, 94, 0.4);
}

.mb-mode-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.mb-back-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #9ca3af;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.mb-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.mb-mode-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mb-mode-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.mb-mode-card.quick .mb-mode-icon {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.mb-mode-card.deep .mb-mode-icon,
.mb-mode-card.deep-voice .mb-mode-icon {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
}

.mb-mode-card.deep-text .mb-mode-icon {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.mb-mode-card-title {
    font-size: 16px;
    font-weight: 700;
}

.mb-mode-card-desc {
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.5;
}

.mb-mode-card-example {
    font-size: 11px;
    color: #4b5563;
    font-style: italic;
    margin-top: 4px;
}

/* VAD Indicator */
.mb-vad-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: #9ca3af;
}

.mb-vad-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4b5563;
    transition: background 0.3s ease;
}

.mb-vad-dot.active {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

/* Deep Analysis UI */
.mb-deep-result {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.6;
    color: #e5e7eb;
}

.mb-deep-thinking {
    font-size: 11px;
    color: #6b7280;
    font-style: italic;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mb-deep-thinking::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid #4b5563;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Text Input Group */
.mb-input-group {
    display: flex;
    gap: 8px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 4px;
}

.mb-text-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
}

.mb-send-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mb-send-btn:hover:not(:disabled) {
    background: #2563eb;
}

.mb-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* TTS Toggle */
.mb-input-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.mb-tts-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #9ca3af;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 20px;
    transition: all 0.2s;
}

.mb-tts-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.mb-tts-toggle input {
    margin: 0;
    cursor: pointer;
}

/* Textarea Auto-resize Adjustment */
.mb-text-input {
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
    flex: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
}