/* ============================================
   ADVANCED AI CHATBOT STYLING
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --secondary-color: #ec4899;
    --background-dark: #0f172a;
    --background-light: #f8fafc;
    --surface-dark: #1e293b;
    --surface-light: #ffffff;
    --text-dark: #f1f5f9;
    --text-light: #1e293b;
    --border-color: #334155;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
    
    color-scheme: dark;
}

body.light-theme {
    --background-dark: #f8fafc;
    --surface-dark: #ffffff;
    --text-dark: #1e293b;
    --border-color: #e2e8f0;
    color-scheme: light;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--background-dark) 0%, #1a1f35 100%);
    color: var(--text-dark);
    overflow: hidden;
    height: 100vh;
}

/* ============================================
   LAYOUT & CONTAINER
   ============================================ */

.container {
    display: grid;
    grid-template-columns: 1fr 280px;
    grid-template-rows: auto 1fr;
    height: 100vh;
    gap: 1px;
    background: var(--border-color);
}

.header {
    grid-column: 1 / -1;
    background: var(--surface-dark);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    font-size: 1.8rem;
    animation: spin 3s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.header-controls {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-icon:active {
    transform: translateY(0);
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: rgba(241, 245, 249, 0.7);
}

.status {
    padding: 4px 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 12px;
    color: var(--success-color);
    font-weight: 500;
}

.indicator {
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   CHAT CONTAINER
   ============================================ */

.chat-container {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    display: flex;
    flex-direction: column;
    background: var(--background-dark);
    overflow: hidden;
}

.messages-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    scroll-behavior: smooth;
}

.messages-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-section {
    text-align: center;
    padding: 48px 24px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.05));
    border-radius: 16px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.welcome-section h2 {
    font-size: 2rem;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-section p {
    font-size: 1rem;
    color: rgba(241, 245, 249, 0.7);
    margin-bottom: 24px;
}

.quick-prompts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.prompt-btn {
    padding: 12px 16px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    color: var(--text-dark);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.875rem;
    font-weight: 500;
}

.prompt-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
}

/* MESSAGE STYLES */

.message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
    margin-bottom: 8px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--surface-dark);
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message-meta {
    font-size: 0.75rem;
    color: rgba(241, 245, 249, 0.5);
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { opacity: 0.5; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-10px); }
}

/* CODE BLOCK STYLING */

.code-block {
    background: #0f0f0f;
    border-left: 3px solid var(--primary-color);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    margin: 8px 0;
}

.code-block code {
    color: #58a6ff;
}

/* ============================================
   INPUT SECTION
   ============================================ */

.input-section {
    background: var(--surface-dark);
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
    box-shadow: var(--shadow-lg);
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-container {
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    transition: all var(--transition-fast);
}

.input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-field {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dark);
    outline: none;
    font-size: 1rem;
    padding: 12px 0;
    font-family: inherit;
}

.input-field::placeholder {
    color: rgba(241, 245, 249, 0.5);
}

.input-actions {
    display: flex;
    gap: 6px;
}

.btn-voice, .btn-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-voice {
    background: rgba(236, 72, 153, 0.2);
    color: var(--secondary-color);
}

.btn-voice:hover {
    background: rgba(236, 72, 153, 0.3);
}

.btn-send {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-weight: 600;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-send:active {
    transform: translateY(0);
}

.input-info {
    font-size: 0.75rem;
    color: rgba(241, 245, 249, 0.5);
    text-align: right;
}

.voice-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    padding: 8px 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
    color: var(--success-color);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.voice-indicator.hidden {
    display: none;
}

.listening-dot {
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    background: var(--surface-dark);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px 16px;
}

.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
}

.settings-group {
    margin-bottom: 16px;
}

.settings-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(241, 245, 249, 0.8);
    margin-bottom: 6px;
}

.select-control {
    width: 100%;
    padding: 6px 10px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-dark);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.select-control:hover {
    border-color: var(--primary-color);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-dark);
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

.stats {
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
}

.stats h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-dark);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 8px;
}

.stat-label {
    color: rgba(241, 245, 249, 0.6);
}

.stat-value {
    color: var(--primary-color);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* ============================================
   NOTIFICATIONS
   ============================================ */

.notification-area {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    pointer-events: none;
}

.notification {
    padding: 12px 16px;
    background: var(--surface-dark);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    pointer-events: auto;
    max-width: 300px;
    font-size: 0.875rem;
}

.notification.success {
    border-left-color: var(--success-color);
    color: var(--success-color);
}

.notification.error {
    border-left-color: var(--error-color);
    color: var(--error-color);
}

.notification.warning {
    border-left-color: var(--warning-color);
    color: var(--warning-color);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        grid-column: 1 / -1;
        grid-row: auto;
        max-height: 150px;
        overflow-x: auto;
        display: flex;
        gap: 20px;
        padding: 12px 16px;
    }
    
    .settings-group {
        min-width: 150px;
    }
}

@media (max-width: 768px) {
    .title {
        font-size: 1.2rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .messages-wrapper {
        padding: 16px;
    }
    
    .quick-prompts {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   THEME VARIANTS
   ============================================ */

body.light-theme .message.user .message-content {
    color: white;
}

body.light-theme .welcome-section {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(236, 72, 153, 0.03));
}

body.light-theme .input-container {
    background: rgba(99, 102, 241, 0.03);
}

body.light-theme .code-block {
    background: #f5f5f5;
}

body.light-theme .code-block code {
    color: #0066cc;
}
