/* ============================================
   AI Voice Assistant - Premium Dark Theme
   ============================================ */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.08);
    --accent-blue: #3b82f6;
    --accent-violet: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --user-bubble: linear-gradient(135deg, #3b82f6, #6366f1);
    --ai-bubble: rgba(30, 41, 59, 0.8);
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* Animated Background Orbs */
.bg-orbs {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 400px; height: 400px;
    background: var(--accent-blue);
    top: -100px; left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 350px; height: 350px;
    background: var(--accent-violet);
    bottom: -50px; right: -50px;
    animation-delay: -7s;
}

.orb-3 {
    width: 300px; height: 300px;
    background: var(--accent-cyan);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(20px, 10px) scale(1.02); }
}

/* Layout Wrapper */
.layout-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    height: 100dvh;
}

/* Sidebar */
.sidebar {
    width: 72px;
    height: 100dvh;
    background: rgba(10, 14, 26, 0.9);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px 0;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.sidebar:hover {
    width: 160px;
}

.sidebar-top,
.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.25s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-btn .material-icons-round {
    font-size: 22px;
    flex-shrink: 0;
}

.sidebar-label {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar:hover .sidebar-label {
    opacity: 1;
}

.sidebar-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}

.sidebar-btn.active {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.12);
    border-left: 3px solid var(--accent-blue);
}

.sidebar-btn.active .material-icons-round {
    color: var(--accent-blue);
}

/* App Container */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-width: 0;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
}

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

.logo-icon {
    font-size: 28px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Voice Toggle */
.voice-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
}

.toggle-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--accent-blue);
    border-radius: 50px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    top: 3px; left: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-violet);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.status-dot {
    width: 10px; height: 10px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

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

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

.chat-area::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 10px;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    gap: 16px;
    animation: fadeIn 0.8s ease;
}

.welcome-icon {
    width: 80px; height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border-radius: 24px;
    font-size: 40px;
    animation: wave 2s ease-in-out infinite;
}

.welcome-icon span {
    font-size: 40px;
    color: white;
}

@keyframes wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(15deg); }
    75% { transform: rotate(-10deg); }
}

.welcome-message h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 400px;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
}

.quick-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quick-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: translateY(-2px);
}

.quick-btn .material-icons-round {
    font-size: 18px;
}

/* Chat Bubbles */
.message {
    display: flex;
    gap: 10px;
    max-width: 80%;
    animation: slideIn 0.4s ease;
}

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

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

.message-avatar {
    width: 36px; height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--user-bubble);
    color: white;
}

.message.ai .message-avatar {
    background: var(--accent-gradient);
    color: white;
}

.message-content {
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.6;
    position: relative;
}

.message.user .message-content {
    background: var(--user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    background: var(--ai-bubble);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(10px);
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.message.ai .message-time {
    text-align: left;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 20px;
}

.typing-indicator .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Input Area */
.input-area {
    padding: 16px 24px 24px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Mic Button */
.mic-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.mic-btn {
    position: relative;
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
    z-index: 2;
}

.mic-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 30px rgba(59, 130, 246, 0.5);
}

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

.mic-icon {
    font-size: 28px;
    color: white;
    z-index: 3;
}

.mic-btn.listening {
    background: linear-gradient(135deg, #ef4444, #f97316);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
    animation: mic-pulse 1.5s ease-in-out infinite;
}

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

/* Pulse Rings */
.pulse-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--accent-blue);
    opacity: 0;
    pointer-events: none;
}

.mic-btn.listening .pulse-ring {
    animation: pulse-ring-anim 2s ease-out infinite;
}

.pulse-2 { animation-delay: 0.4s !important; }
.pulse-3 { animation-delay: 0.8s !important; }

@keyframes pulse-ring-anim {
    0% { transform: scale(1); opacity: 0.6; border-color: #ef4444; }
    100% { transform: scale(1.8); opacity: 0; border-color: #ef4444; }
}

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

/* Text Input */
.text-input-area {
    display: flex;
    width: 100%;
    gap: 8px;
}

#textInput {
    flex: 1;
    padding: 12px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

#textInput:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

#textInput::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.send-btn .material-icons-round {
    font-size: 20px;
}

/* AI Speaking indicator */
.speaking-wave {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 8px;
    vertical-align: middle;
}

.speaking-wave .bar {
    width: 3px;
    background: var(--accent-blue);
    border-radius: 2px;
    animation: wave-bar 1s ease-in-out infinite;
}

.speaking-wave .bar:nth-child(1) { height: 8px; animation-delay: 0s; }
.speaking-wave .bar:nth-child(2) { height: 14px; animation-delay: 0.15s; }
.speaking-wave .bar:nth-child(3) { height: 10px; animation-delay: 0.3s; }
.speaking-wave .bar:nth-child(4) { height: 16px; animation-delay: 0.45s; }
.speaking-wave .bar:nth-child(5) { height: 8px; animation-delay: 0.6s; }

@keyframes wave-bar {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1.2); }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
    .app-container {
        max-width: 1000px;
    }
}

/* Tablet Landscape (769px - 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        width: 56px;
    }
    .sidebar:hover {
        width: 140px;
    }
    .sidebar-btn {
        padding: 12px 16px;
    }
    .welcome-message h2 {
        font-size: 22px;
    }
    .mic-btn {
        width: 58px;
        height: 58px;
    }
}

/* Tablet Portrait (481px - 768px) */
@media (max-width: 768px) {
    .sidebar {
        width: 50px;
    }
    .sidebar:hover {
        width: 50px;
    }
    .sidebar-label {
        display: none;
    }
    .sidebar-btn {
        padding: 12px 0;
        justify-content: center;
    }
    .sidebar-btn.active {
        border-left: 2px solid var(--accent-blue);
    }
    .header {
        padding: 12px 16px;
    }
    .header h1 {
        font-size: 16px;
    }
    .toggle-label {
        font-size: 11px;
    }
    .voice-toggle {
        padding: 4px 10px;
    }
    .chat-area {
        padding: 16px;
    }
    .input-area {
        padding: 12px 16px 20px;
    }
    .message {
        max-width: 85%;
    }
    .welcome-message h2 {
        font-size: 20px;
    }
    .welcome-message p {
        font-size: 13px;
    }
    .mic-btn {
        width: 56px;
        height: 56px;
    }
    .mic-icon {
        font-size: 24px;
    }
}

/* Phone (up to 480px) */
@media (max-width: 480px) {
    /* Move sidebar to bottom as tab bar */
    .layout-wrapper {
        flex-direction: column;
        height: 100dvh;
    }

    .app-container {
        flex: 1;
        height: auto;
        padding-bottom: 0;
        min-height: 0;
    }

    .sidebar {
        width: 100%;
        height: auto; /* Let content dictate height */
        min-height: 60px; /* Taller for easier thumb access */
        flex-direction: row;
        order: 2; /* Move below app-container in flex column */
        border-right: none;
        border-top: 1px solid var(--glass-border);
        padding: 4px 0;
        position: relative; /* Not fixed! Stacked below app-container */
        z-index: 10;
        background: rgba(10, 14, 26, 0.95);
        flex-shrink: 0; /* Prevent sidebar from shrinking */
    }

    .sidebar:hover {
        width: 100%;
    }

    .sidebar-top,
    .sidebar-bottom {
        flex-direction: row;
        gap: 0;
    }

    .sidebar-top {
        flex: 1;
        justify-content: space-around;
    }

    .sidebar-bottom {
        justify-content: center;
    }

    .sidebar-btn {
        padding: 8px 12px;
        justify-content: center;
        flex-direction: column;
        gap: 2px;
    }

    .sidebar-label {
        display: block;
        opacity: 1;
        font-size: 9px;
    }

    .sidebar-btn .material-icons-round {
        font-size: 20px;
    }

    .sidebar-btn.active {
        border-left: none;
        border-top: 2px solid var(--accent-blue);
    }

    /* Header */
    .header {
        padding: 10px 14px;
    }
    .header h1 {
        font-size: 14px;
    }
    .logo-icon {
        font-size: 22px;
    }
    .toggle-label {
        display: none;
    }
    .voice-toggle {
        padding: 4px 8px;
        gap: 4px;
    }
    .toggle-switch {
        width: 36px;
        height: 20px;
    }
    .toggle-slider::before {
        width: 14px;
        height: 14px;
        top: 3px;
        left: 3px;
    }
    .toggle-switch input:checked + .toggle-slider::before {
        transform: translateX(16px);
    }

    /* Chat */
    .chat-area {
        padding: 12px;
    }
    .message {
        max-width: 92%;
    }
    .message-content {
        padding: 10px 14px;
        font-size: 13px;
    }
    .message-avatar {
        width: 30px;
        height: 30px;
        border-radius: 10px;
    }
    .message-avatar .material-icons-round {
        font-size: 16px;
    }
    .message-time {
        font-size: 10px;
    }

    /* Welcome */
    .welcome-icon {
        width: 64px;
        height: 64px;
        border-radius: 18px;
    }
    .welcome-icon span {
        font-size: 32px;
    }
    .welcome-message h2 {
        font-size: 18px;
    }
    .welcome-message p {
        font-size: 12px;
        max-width: 280px;
    }
    .quick-actions {
        gap: 6px;
    }
    .quick-btn {
        padding: 8px 12px;
        font-size: 11px;
    }
    .quick-btn .material-icons-round {
        font-size: 16px;
    }

    /* Input Area */
    .input-area {
        padding: 10px 12px 14px;
        gap: 10px;
    }
    .mic-btn {
        width: 52px;
        height: 52px;
    }
    .mic-icon {
        font-size: 22px;
    }
    .mic-status {
        font-size: 11px;
    }
    #textInput {
        padding: 10px 14px;
        font-size: 13px;
    }
    .send-btn {
        width: 40px;
        height: 40px;
    }
    .send-btn .material-icons-round {
        font-size: 18px;
    }

    /* Background */
    .orb-1 { width: 200px; height: 200px; }
    .orb-2 { width: 180px; height: 180px; }
    .orb-3 { width: 150px; height: 150px; }
}

/* Very small phones (up to 360px) */
@media (max-width: 360px) {
    .header h1 { font-size: 13px; }
    .welcome-message h2 { font-size: 16px; }
    .quick-btn { padding: 6px 10px; font-size: 10px; }
    .mic-btn { width: 48px; height: 48px; }
    .sidebar-btn .material-icons-round { font-size: 18px; }
    .sidebar-label { font-size: 8px; }
}

