/* IA Voice Chile - Modern Light Theme */

:root {
    /* Modern blue color scheme */
    --primary: #0052cc;
    --primary-light: #0066ff;
    --primary-lighter: #3385ff;
    --primary-bg: #e6f0ff;
    
    /* Light backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f0f2f5;
    --bg-hover: #e8eaed;
    --bg-active: #dfe1e5;
    
    /* Text colors */
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;
    --text-light: #70757a;
    
    /* Borders */
    --border-light: #e8eaed;
    --border-medium: #dadce0;
    --border-focus: var(--primary-light);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(60,64,67,0.1);
    --shadow-md: 0 2px 6px 2px rgba(60,64,67,0.15);
    --shadow-lg: 0 1px 3px 1px rgba(60,64,67,0.15);
    --shadow-xl: 0 4px 16px 3px rgba(60,64,67,0.15);
    
    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

/* Modern Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-light);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.hidden {
    width: 0;
    border-right: none;
}

/* Mobile overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-overlay.show {
    display: block;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-close-btn {
    display: none;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.sidebar-content {
    padding: 1rem;
}

.new-chat-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.new-chat-btn:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.new-chat-btn svg {
    width: 18px;
    height: 18px;
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.history-item {
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.history-item:hover {
    background: var(--bg-hover);
}

.history-item.active {
    background: var(--bg-active);
    font-weight: 500;
}

.history-preview {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-light);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.user-info:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    height: 100vh;
    overflow: hidden;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-primary);
}

.chat-header h1 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 3rem 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-message h2 {
    font-size: 2rem;
    font-weight: 300;
    margin-bottom: 1rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.welcome-message p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Messages */
.message {
    padding: 1.5rem 0;
}

.message.user-message {
    background: var(--bg-primary);
}

.message.assistant-message {
    background: var(--bg-secondary);
}

.message-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.message-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

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

.assistant-message .message-avatar {
    background: var(--primary-bg);
    color: var(--primary);
}

.message-avatar svg {
    width: 18px;
    height: 18px;
}

.message-author {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.message-content {
    margin-left: 48px;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.message-content strong {
    font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}

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

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

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

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Chat Input */
.chat-input-container {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--border-light);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.chat-input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: flex-end;
    padding: 0.75rem;
    transition: all 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    outline: none;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    padding: 0 0.75rem;
    font-family: inherit;
}

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

.input-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.voice-btn,
.send-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.voice-btn:hover,
.send-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.voice-btn.recording {
    background: var(--primary);
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 102, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(0, 102, 255, 0);
    }
}

.send-btn {
    color: var(--primary);
}

/* Voice Controls */
.voice-controls {
    display: flex;
    gap: 0.5rem;
    margin-right: 0.5rem;
}

.voice-toggle-btn,
.continuous-btn {
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.voice-toggle-btn:hover,
.continuous-btn:hover {
    border-color: var(--border-medium);
    background: var(--bg-hover);
}

.continuous-btn.active {
    background: var(--primary-bg);
    color: var(--primary);
    border-color: var(--primary-light);
}

/* Voice Indicator */
.voice-indicator {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
}

.voice-visualizer {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}

.voice-bar {
    width: 3px;
    height: 12px;
    background: white;
    border-radius: 3px;
    animation: wave 1s ease-in-out infinite;
}

.voice-bar:nth-child(1) { animation-delay: 0s; }
.voice-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-bar:nth-child(4) { animation-delay: 0.3s; }
.voice-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
    0%, 100% { height: 12px; }
    50% { height: 24px; }
}

/* Continuous Listening Indicator */
.continuous-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--primary-bg);
    color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
}

.continuous-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Scroll to Bottom Button */
.scroll-to-bottom-btn {
    position: fixed;
    bottom: 120px;
    right: 30px;
    width: 40px;
    height: 40px;
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.scroll-to-bottom-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.scroll-to-bottom-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.new-messages-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        position: relative;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px !important;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-xl);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
    }
    
    .sidebar-close-btn {
        display: flex !important;
        width: 36px;
        height: 36px;
        border: none;
        background: transparent;
        border-radius: var(--radius-sm);
        cursor: pointer;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        transition: all 0.2s;
    }
    
    .sidebar-close-btn:hover {
        background: var(--bg-hover);
    }
    
    /* Mobile overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .mobile-overlay.show {
        display: block;
    }
    
    .main-content {
        width: 100%;
        margin-left: 0 !important;
    }
    
    .chat-container {
        max-width: 100%;
        padding: 0;
    }
    
    .chat-header {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    
    .chat-header h1 {
        font-size: 1rem;
    }
    
    .chat-messages {
        padding: 1rem 0;
    }
    
    .message-wrapper {
        padding: 0 1rem;
    }
    
    .message-content {
        margin-left: 40px;
        font-size: 0.9375rem;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
    }
    
    .welcome-message {
        padding: 2rem 1rem;
    }
    
    .welcome-message h2 {
        font-size: 1.5rem;
    }
    
    .welcome-message p {
        font-size: 0.875rem;
    }
    
    .chat-input-container {
        padding: 0.75rem;
    }
    
    .chat-input-wrapper {
        padding: 0.5rem;
    }
    
    #messageInput {
        font-size: 0.9375rem;
        padding: 0 0.5rem;
    }
    
    .voice-btn,
    .send-btn {
        width: 32px;
        height: 32px;
    }
    
    .chat-actions {
        gap: 0.25rem;
    }
    
    .icon-btn {
        width: 32px;
        height: 32px;
    }
    
    .voice-controls {
        display: none;
    }
    
    .continuous-indicator {
        top: auto;
        bottom: 120px;
        right: 10px;
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    .voice-indicator {
        bottom: 80px;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .scroll-to-bottom-btn {
        bottom: 100px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
}

/* Smaller mobile devices */
@media (max-width: 480px) {
    .chat-header h1 {
        font-size: 0.875rem;
    }
    
    .message-content {
        font-size: 0.875rem;
    }
    
    #messageInput {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-messages {
        padding: 0.5rem 0;
    }
    
    .chat-input-container {
        padding: 0.5rem;
    }
    
    .welcome-message {
        padding: 1rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #252525;
        --bg-tertiary: #2a2a2a;
        --bg-hover: #333333;
        --bg-active: #3a3a3a;
        
        --text-primary: #e5e5e5;
        --text-secondary: #b0b0b0;
        --text-muted: #808080;
        --text-light: #606060;
        
        --border-light: #333333;
        --border-medium: #404040;
        
        --primary-bg: #003d99;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}