/**
 * NOVALTZEN SUPPORTVOICE — EMBEDDABLE WIDGET STYLESHEET
 * High-performance, glassmorphic dark theme, responsive bottom-sheet on mobile.
 */

:root {
    --bg-base: #070a10;
    --bg-surface: #0e131f;
    --bg-surface-elevated: #151d2f;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(0, 229, 255, 0.35);
    --accent-cyan: #00e5ff;
    --accent-blue: #0070f3;
    --accent-indigo: #6366f1;
    --accent-emerald: #10b981;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --danger: #ef4444;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --shadow-window: 0 25px 60px rgba(0, 0, 0, 0.7);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.widget-body {
    background: transparent;
    font-family: var(--font-sans);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    user-select: none;
}

.widget-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: var(--bg-base);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-window);
    overflow: hidden;
    position: relative;
}

/* Header */
.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: rgba(14, 19, 31, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 20;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(0, 112, 243, 0.3));
    border: 1px solid var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-icon {
    font-size: 16px;
}

.avatar-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 9px;
    height: 9px;
    background: var(--accent-emerald);
    border: 2px solid var(--bg-surface);
    border-radius: 50%;
}

.brand-meta {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 2px;
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: #06090e;
    font-weight: 700;
}

.lang-selector {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    padding: 5px 6px;
    cursor: pointer;
    outline: none;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.icon-btn.close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* Page Context Pill Bar */
.context-pill-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: rgba(0, 229, 255, 0.06);
    border-bottom: 1px solid rgba(0, 229, 255, 0.15);
    font-size: 11px;
    color: var(--accent-cyan);
}

.context-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Audio Visualizer & State Badge */
.visualizer-container {
    padding: 12px 18px 8px 18px;
    background: linear-gradient(180deg, rgba(14, 19, 31, 0.7) 0%, transparent 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.visualizer-canvas {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-secondary);
}

.status-pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
}

/* Chat Timeline */
.chat-timeline {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.chat-timeline::-webkit-scrollbar {
    width: 5px;
}
.chat-timeline::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
}

.chat-msg.assistant {
    align-self: flex-start;
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(0, 112, 243, 0.3));
    border: 1px solid var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.chat-msg.user .msg-avatar {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(168, 85, 247, 0.3));
    border-color: rgba(168, 85, 247, 0.4);
}

.msg-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    user-select: text;
}

.chat-msg.assistant .msg-bubble {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}

.chat-msg.user .msg-bubble {
    background: linear-gradient(135deg, #0070f3, #0051b3);
    color: #ffffff;
    border-top-right-radius: 4px;
}

/* Citations & Replay Bar */
.msg-meta-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
}

.citation-tag {
    background: rgba(0, 229, 255, 0.1);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 229, 255, 0.25);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    text-decoration: none;
    font-family: var(--font-mono);
}

.audio-replay-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.audio-replay-btn:hover {
    color: var(--accent-cyan);
}

/* Quick Suggestion Chips */
.action-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip:hover {
    background: rgba(0, 229, 255, 0.1);
    border-color: var(--accent-cyan);
    color: #ffffff;
    transform: translateY(-1px);
}

/* Inline Booking Drawer Modal */
.lead-modal-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-accent);
    border-radius: 16px 16px 0 0;
    padding: 18px;
    z-index: 50;
    box-shadow: 0 -15px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 90%;
    overflow-y: auto;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-cyan);
}

.drawer-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
}

.drawer-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 8px 10px;
    color: #ffffff;
    font-family: var(--font-sans);
    font-size: 12px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .col {
    flex: 1;
}

.submit-booking-btn {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: #06090e;
    font-weight: 700;
    font-size: 13px;
    padding: 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    margin-top: 6px;
    transition: opacity 0.2s ease;
}

.submit-booking-btn:hover {
    opacity: 0.95;
}

/* Booking Confirmation */
.booking-confirmation {
    text-align: center;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.conf-icon {
    font-size: 36px;
}

.calendar-btn {
    display: inline-block;
    background: rgba(0, 229, 255, 0.15);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}

.btn-return-chat {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
}

/* Footer / Input Bar */
.widget-footer {
    padding: 12px 18px;
    background: rgba(14, 19, 31, 0.9);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
}

.voice-controls {
    display: flex;
    justify-content: center;
}

.mic-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.15), rgba(0, 112, 243, 0.25));
    border: 1px solid var(--border-accent);
    padding: 10px 18px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #ffffff;
}

.mic-action-btn:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
    transform: translateY(-1px);
}

.mic-action-btn.listening {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.4));
    border-color: #ef4444;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.4);
    animation: pulse-recording 1.6s infinite;
}

.mic-action-btn.speaking {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.4));
    border-color: #10b981;
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.4);
}

@keyframes pulse-recording {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.mic-icon-wrap {
    font-size: 18px;
}

.mic-text-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.mic-main-label {
    font-size: 13px;
    font-weight: 700;
}

.mic-sub-label {
    font-size: 10px;
    color: var(--text-secondary);
}

.text-controls {
    display: flex;
    gap: 8px;
}

.text-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 25px;
    padding: 9px 16px;
    color: #ffffff;
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.text-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: #06090e;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.send-btn:hover {
    transform: scale(1.06);
}

.footer-meta {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    padding: 0 4px;
}

/* Mobile Adjustments & Safe Areas */
@media (max-width: 768px) {
    .widget-shell {
        border-radius: 20px 20px 0 0;
        border-bottom: none;
    }
    .widget-footer {
        padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    }
}
