/* ============================================================================
   FleetBot — Chat Interface Styles (Dark Theme)
   ============================================================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2231;
    --bg-input: #252a3a;
    --text-primary: #e8eaf0;
    --text-secondary: #8b92a5;
    --text-muted: #5a6178;
    --accent-red: #dc3545;
    --accent-red-soft: rgba(220, 53, 69, 0.12);
    --accent-blue: #0dcaf0;
    --border-color: #2a2f3f;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

/* ============================================================================
   LOGIN PAGE
   ============================================================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at center, #1a1d27 0%, #0f1117 70%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* Form overrides */
.form-control, .input-group-text {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus {
    background: var(--bg-input);
    border-color: var(--accent-red);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.15);
}

.input-group-text {
    color: var(--text-muted);
}

.form-label {
    color: var(--text-secondary);
}

/* ============================================================================
   CHAT PAGE LAYOUT
   ============================================================================ */

.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-input-area {
    padding: 12px 20px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-input-area .form-control {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    padding: 12px 16px;
}

.chat-input-area .btn {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 20px;
}

/* ============================================================================
   MESSAGES
   ============================================================================ */

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--accent-red-soft);
    color: var(--accent-red);
    font-size: 1rem;
}

.message-avatar.user-av {
    background: rgba(13, 202, 240, 0.12);
    color: var(--accent-blue);
}

.message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 0.875rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.user-message .message-bubble {
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.25);
}

.message-bubble p {
    margin: 0 0 8px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul, .message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin-bottom: 4px;
}

.message-bubble code {
    background: rgba(220, 53, 69, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.message-bubble strong {
    color: var(--text-primary);
}

/* ============================================================================
   CHAT TABLES (Markdown rendered)
   ============================================================================ */

.chat-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.78rem;
    overflow-x: auto;
    display: block;
}

.chat-table th, .chat-table td {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

.chat-table th {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
}

.chat-table td {
    color: var(--text-primary);
}

.chat-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

/* ============================================================================
   QUICK ACTIONS
   ============================================================================ */

.quick-actions {
    display: flex;
    gap: 8px;
    padding: 8px 20px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.quick-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-btn:hover {
    border-color: var(--accent-red);
    color: var(--text-primary);
    background: var(--accent-red-soft);
}

.quick-btn i {
    margin-right: 4px;
}

/* ============================================================================
   TYPING INDICATOR
   ============================================================================ */

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

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

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

/* ============================================================================
   SCROLLBAR
   ============================================================================ */

.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: var(--bg-input);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

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

@media (max-width: 768px) {
    .message {
        max-width: 95%;
    }

    .chat-messages {
        padding: 12px;
    }

    .quick-actions {
        padding: 8px 12px;
    }

    .quick-btn {
        font-size: 0.72rem;
        padding: 6px 10px;
    }

    .chat-header {
        padding: 10px 12px;
    }

    .chat-input-area {
        padding: 10px 12px 14px;
    }
}

/* ============================================================================
   ALERT OVERRIDES
   ============================================================================ */

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.3);
    color: #f5c6cb;
}

/* ============================================================================
   BADGE OVERRIDES
   ============================================================================ */

.bg-success-subtle {
    background-color: rgba(25, 135, 84, 0.15) !important;
}
