/* Custom Premium Styling for Sarvam AI Chatbot */
:root {
    --bg-dark: #09090e;
    --card-bg: rgba(18, 18, 29, 0.45);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(124, 58, 237, 0.3);
    
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.4);
    --secondary: #06b6d4;
    --secondary-glow: rgba(6, 182, 212, 0.4);
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Glowing Background Blobs */
.glow-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: floatBlob 20s infinite alternate ease-in-out;
}

.blob-purple {
    top: -10%;
    left: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
}

.blob-blue {
    bottom: -10%;
    right: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    animation-delay: -5s;
}

.blob-cyan {
    top: 40%;
    left: 50%;
    width: 35vw;
    height: 35vw;
    background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
    animation-delay: -10s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.1); }
}

/* Glassmorphism utility */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Application Container Layout */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* Sidebar Settings Styling */
.sidebar {
    padding: 30px 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.logo-icon {
    font-size: 24px;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px var(--primary-glow));
}

.sidebar-header h2 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 24px;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-header .subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-group h3 {
    font-family: var(--font-heading);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #e9d5ff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-group label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: -6px;
}

/* Custom inputs, selects */
.input-wrapper {
    position: relative;
    display: flex;
    width: 100%;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 42px 12px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: #fff;
    font-family: var(--font-body);
    font-size: 13px;
    outline: none;
    transition: var(--transition-smooth);
}

.input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

#toggleApiKey {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition-smooth);
}

#toggleApiKey:hover {
    color: #fff;
}

select {
    width: 100%;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: #fff;
    font-family: var(--font-body);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    transition: var(--transition-smooth);
}

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Custom Switch/Toggle styling */
.toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    margin-top: 4px;
}

.toggle-label-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toggle-label-container label {
    font-size: 13px;
    color: var(--text-main) !important;
    font-weight: 600;
}

.toggle-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .3s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background-color: var(--primary-glow);
    border-color: var(--primary);
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
    background-color: #fff;
    box-shadow: 0 0 8px var(--primary);
}

.help-text {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.language-pill-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: default;
    transition: var(--transition-smooth);
}

.pill:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--primary);
    color: #fff;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.green {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Top Nav Header */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(13, 13, 23, 0.3);
}

.header-info h1 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
}

.header-info p {
    font-size: 13px;
    color: var(--text-muted);
}

.btn {
    padding: 10px 16px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--error);
    color: #fca5a5;
}

/* Chat History Display */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Scrollbar tweaks */
.chat-history::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Welcome Info Box */
.welcome-box {
    align-self: center;
    max-width: 650px;
    padding: 32px;
    border-radius: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin: auto 0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
    border: 1px solid rgba(139, 92, 246, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #e9d5ff;
    margin-bottom: 8px;
    animation: floatIcon 4s infinite alternate ease-in-out;
}

@keyframes floatIcon {
    0% { transform: translateY(0); }
    100% { transform: translateY(-8px); }
}

.welcome-box h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
}

.welcome-box p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

.features-list {
    list-style: none;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
    width: 100%;
}

.features-list li {
    font-size: 13px;
    color: var(--text-main);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.features-list li i {
    color: var(--secondary);
    margin-top: 3px;
}

.prompt-hint {
    background: rgba(0, 0, 0, 0.25);
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    font-size: 12px !important;
}

/* Chat Message Bubbles */
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    gap: 6px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

.message-wrapper.bot {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.message-wrapper.user .message-bubble {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(124, 58, 237, 0.2));
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-bottom-right-radius: 4px;
    color: #fff;
}

.message-wrapper.bot .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    color: #e5e7eb;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.lang-tag {
    padding: 2px 6px;
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid var(--secondary);
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    color: var(--secondary);
    text-transform: uppercase;
}

.user .lang-tag {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--primary);
    color: #c084fc;
}

.play-voice-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px;
    transition: var(--transition-smooth);
    margin-left: 6px;
}

.play-voice-btn:hover {
    color: var(--secondary);
    transform: scale(1.1);
}

/* Loading/typing indicator */
.typing-dots {
    display: flex;
    gap: 5px;
    padding: 6px 10px;
    align-items: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    display: inline-block;
    animation: bounceDot 1.4s infinite ease-in-out both;
}

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

@keyframes bounceDot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Interaction Panel Footer */
.interaction-panel {
    border-top: 1px solid var(--border-color);
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: rgba(13, 13, 23, 0.5);
}

.visualizer-container {
    width: 100%;
    max-width: 600px;
    height: 50px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

#visualizerCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.status-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#interactionStatus {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: var(--transition-smooth);
    background: rgba(18, 18, 29, 0.8);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.keyboard-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* Pulsing Mic Button Design */
.record-btn {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    outline: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 24px;
    box-shadow: 0 8px 24px var(--primary-glow);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(139, 92, 246, 0.6);
}

.record-btn:active {
    transform: scale(0.95);
}

.record-btn .stop-icon {
    display: none;
    font-size: 20px;
}

/* Pulse rings for active state */
.pulse-ring, .pulse-ring-outer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    border: 2px solid var(--secondary);
    opacity: 0;
    pointer-events: none;
}

/* Recording State */
.record-btn.recording {
    background: linear-gradient(135deg, var(--error), #f43f5e);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
}

.record-btn.recording .mic-icon {
    display: none;
}

.record-btn.recording .stop-icon {
    display: block;
}

.record-btn.recording .pulse-ring {
    animation: pulsate 1.5s infinite cubic-bezier(0.215, 0.610, 0.355, 1);
    border-color: var(--error);
}

.record-btn.recording .pulse-ring-outer {
    animation: pulsate-outer 1.5s infinite cubic-bezier(0.215, 0.610, 0.355, 1);
    border-color: #f43f5e;
}

@keyframes pulsate {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes pulsate-outer {
    0% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.4); opacity: 0.2; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* Text Input & TTS Buttons Styling */
.controls-wrapper {
    width: 100%;
    max-width: 680px;
}

.text-input-container {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: center;
}

#textInput {
    flex: 1;
    padding: 12px 18px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    color: #fff;
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: var(--transition-smooth);
}

#textInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 14px var(--primary-glow);
}

.btn-primary-gradient {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    border: none;
}

.btn-primary-gradient:hover {
    background: linear-gradient(135deg, #9d6cfe, #6d28d9);
    box-shadow: 0 4px 16px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-secondary-gradient {
    background: linear-gradient(135deg, var(--secondary), #0284c7);
    color: #fff;
    border: none;
}

.btn-secondary-gradient:hover {
    background: linear-gradient(135deg, #22d3ee, #0369a1);
    box-shadow: 0 4px 16px var(--secondary-glow);
    transform: translateY(-1px);
}

.voice-divider {
    display: flex;
    align-items: center;
    text-align: center;
    width: 100%;
    margin: 8px 0 4px 0;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.voice-divider::before,
.voice-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.voice-divider span {
    padding: 0 10px;
}

.record-controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 4px;
}


/* App Responsive Design */
@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: 98vh;
        width: 98vw;
    }
    
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 20px;
        height: auto;
        gap: 16px;
    }
    
    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .settings-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .settings-group h3 {
        grid-column: span 2;
    }
    
    .sidebar-footer {
        display: none; /* Hide in compact view */
    }
    
    .chat-history {
        padding: 20px;
    }
}
