/* ═══════════════════════════════════════════════════════════════════
   Odoo Chatbot — Premium Design System
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────────── */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.3);
    --accent: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.2);

    --bg-primary: #0a0a0f;
    --bg-secondary: #111119;
    --bg-card: #16161f;
    --bg-input: #1c1c28;
    --bg-hover: #22222f;

    --text-primary: #f0f0f5;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --border: rgba(255, 255, 255, 0.06);
    --border-active: rgba(99, 102, 241, 0.4);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--primary-glow);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* Only chatbot page locks scroll — admin page scrolls freely */
body.chatbot-page {
    overflow: hidden;
}

/* ─── Animated Background ────────────────────────────────────────── */
.bg-pattern {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-pattern::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-glow), transparent 70%);
    top: -200px;
    right: -200px;
    animation: floatOrb 20s ease-in-out infinite;
}

.bg-pattern::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    bottom: -200px;
    left: -200px;
    animation: floatOrb 25s ease-in-out infinite reverse;
}

@keyframes floatOrb {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(50px, -30px) scale(1.1); }
    66% { transform: translate(-30px, 50px) scale(0.9); }
}

/* ─── Main Layout ────────────────────────────────────────────────── */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
}

/* ─── Header ─────────────────────────────────────────────────────── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(22, 22, 31, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.bot-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-glow);
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 15px var(--primary-glow); }
    50% { box-shadow: 0 0 30px var(--primary-glow), 0 0 60px rgba(99, 102, 241, 0.15); }
}

.bot-info h1 {
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 16px;
    text-decoration: none;
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-light);
    border-color: var(--border-active);
}

/* ─── Messages Area ──────────────────────────────────────────────── */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 5px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

/* ─── Message Bubbles ────────────────────────────────────────────── */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.message-content {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.65;
    position: relative;
}

.message.bot .message-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-bottom-right-radius: 4px;
    color: #fff;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content code {
    background: rgba(99, 102, 241, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Fira Code', monospace;
}

.message-content strong {
    color: var(--primary-light);
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    padding: 0 4px;
}

.message.user .message-time {
    text-align: right;
}

/* ─── Typing Indicator ───────────────────────────────────────────── */
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    margin-left: 46px;
}

.typing-indicator.active {
    display: flex;
    gap: 5px;
    align-items: center;
    animation: messageIn 0.3s ease-out;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-light);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ─── Welcome Screen ─────────────────────────────────────────────── */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
    gap: 20px;
    flex: 1;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    box-shadow: var(--shadow-glow);
    animation: pulse-glow 3s ease-in-out infinite;
}

.welcome-screen h2 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-screen p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

.quick-btn {
    padding: 10px 18px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.quick-btn:hover {
    border-color: var(--primary);
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* ─── Input Area ─────────────────────────────────────────────────── */
.input-container {
    padding: 16px 24px 24px;
    background: rgba(22, 22, 31, 0.8);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.message-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    padding: 8px 4px;
    resize: none;
    max-height: 120px;
    min-height: 24px;
    line-height: 1.5;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.input-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: var(--transition);
    flex-shrink: 0;
}

.voice-btn {
    background: transparent;
    color: var(--text-secondary);
}

.voice-btn:hover {
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
}

.voice-btn.recording {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    animation: recording-pulse 1s ease-in-out infinite;
}

@keyframes recording-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.send-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.powered-by {
    text-align: center;
    padding-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
}

.powered-by a {
    color: var(--primary-light);
    text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════════
   Admin Panel Styles
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Admin Layout ───────────────────────────────────────────────── */
.admin-container {
    position: relative;
    z-index: 1;
    max-width: 700px;
    margin: 0 auto;
    padding: 32px 24px;
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.admin-header h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.admin-back {
    padding: 10px 20px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.admin-back:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

/* ─── Login Form ─────────────────────────────────────────────────── */
.login-card {
    max-width: 400px;
    margin: 100px auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    text-align: center;
}

.login-card h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

/* ─── Settings Cards ─────────────────────────────────────────────── */
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.settings-section:hover {
    border-color: var(--border-active);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.section-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.section-icon.ai { background: rgba(99, 102, 241, 0.15); }
.section-icon.odoo { background: rgba(6, 182, 212, 0.15); }
.section-icon.bot { background: rgba(16, 185, 129, 0.15); }
.section-icon.security { background: rgba(245, 158, 11, 0.15); }

.section-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.section-header p {
    font-size: 12px;
    color: var(--text-muted);
}

/* ─── Form Elements ──────────────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ─── Toast Notifications ────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px);
    border: 1px solid;
}

.toast.success {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.toast.error {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.toast.info {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

/* ─── Status Badges ──────────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.status-badge.connected {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.disconnected {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .app-container {
        max-width: 100%;
    }

    .chat-header {
        padding: 12px 16px;
    }

    .messages-container {
        padding: 16px;
    }

    .input-container {
        padding: 12px 16px 16px;
    }

    .message {
        max-width: 92%;
    }

    .welcome-screen h2 {
        font-size: 20px;
    }

    .quick-actions {
        flex-direction: column;
        align-items: center;
    }

    .admin-container {
        padding: 20px 16px;
    }

    .settings-section {
        padding: 20px;
    }

    .admin-header h1 {
        font-size: 22px;
    }
}

/* ─── Markdown Rendering Fixes ───────────────────────────────────── */
.message-content h1, .message-content h2, .message-content h3 {
    margin: 12px 0 8px;
    font-size: 15px;
    font-weight: 600;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.message-content th, .message-content td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
}

.message-content th {
    background: rgba(99, 102, 241, 0.1);
    font-weight: 600;
}

.message-content pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}

.message-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--text-secondary);
}
