/* ==========================================
   AI Assistant - Main Styles
   ========================================== */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ==========================================
   Authentication Pages
   ========================================== */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.auth-card h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
    text-align: center;
}

.auth-card h2 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 32px;
    text-align: center;
}

/* ==========================================
   Forms
   ========================================== */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==========================================
   Buttons
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #475569;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-icon {
    padding: 10px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

/* ==========================================
   Messages & Alerts
   ========================================== */

.error-message,
.success-message,
.info-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.error-message {
    background-color: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.success-message {
    background-color: #d1fae5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.info-message {
    background-color: #dbeafe;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* ==========================================
   Links
   ========================================== */

.auth-link {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* ==========================================
   Chat Interface
   ========================================== */

.chat-container {
    display: flex;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height on mobile */
    width: 100%;
}

.chat-sidebar {
    width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
}

.chat-header {
    padding: 16px 24px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.chat-input-container {
    padding: 16px 24px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
}

.message {
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
}

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

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

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

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

.chat-input-form {
    position: relative;
    width: 100%;
}

.chat-input-form textarea {
    width: 100%;
    resize: none;
    min-height: 80px;
    max-height: 200px;
    padding: 12px 60px 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
}

.chat-input-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chat-input-form button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-input-form #send-btn {
    position: absolute;
    right: 8px;
    bottom: 8px;
}

.chat-input-form #toggle-voice-btn {
    position: absolute;
    right: 56px;
    bottom: 8px;
}

/* ==========================================
   Utility Classes
   ========================================== */

.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 768px) {
    .auth-card {
        padding: 24px;
    }

    .chat-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }

    .chat-main {
        height: 100vh;
        height: 100dvh;
    }

    .chat-input-container {
        position: sticky;
        bottom: 0;
        background: var(--card-bg);
        z-index: 10;
    }

    /* Show mobile menu button */
    #mobile-menu-btn {
        display: inline-flex !important;
    }

    /* Mobile sidebar */
    .chat-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    .chat-sidebar.open {
        left: 0;
    }

    .message-content {
        max-width: 85%;
    }
}

/* ==========================================
   Voice Controls
   ========================================== */

.voice-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.recording-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--error-color);
    animation: pulse 1.5s infinite;
}

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

.audio-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: 8px;
    margin-top: 8px;
}

.audio-player audio {
    flex: 1;
    height: 32px;
}

/* ==========================================
   Spinner & Typing Indicators
   ========================================== */

.spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    animation: typing 1.4s 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% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

#sending-indicator {
    display: flex;
}

.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

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