/* Futuriti AI Chatbot — Mobile-first, WCAG AA Compliant */

:root {
    --futuriti-blue: #056B91;
    --futuriti-dark: #045674;
    --futuriti-olive: #999E24;
    --futuriti-tan: #D7DBC6;
    --text-primary: #1e1e1e;
    --text-secondary: #555;
    --bg-white: #ffffff;
    --bg-gray: #F7F7F7;
    --border-color: #dee2e6;
    --user-bubble: #056B91;
    --user-text: #ffffff;
    --ai-bubble: #f0f3ec;
    --ai-text: #1e1e1e;
    --focus-outline: #056B91;
    --error-red: #C83939;
    --success-green: #248c14;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    background: var(--bg-gray);
    line-height: 1.5;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Skip to content link — WCAG */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--futuriti-blue);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    font-size: 0.875rem;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* Focus indicators — WCAG AA */
*:focus-visible {
    outline: 3px solid var(--focus-outline);
    outline-offset: 2px;
}

/* Header */
.chat-header {
    background: var(--futuriti-blue);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    z-index: 10;
    /* border-radius: 12px 12px 0 0; */
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.header-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-family: inherit;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.header-btn:hover,
.header-btn:focus-visible {
    background: rgba(255, 255, 255, 0.25);
}

/* Main chat area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    background: var(--bg-white);
    min-height: 0;
    overflow: hidden;
}

/* Messages area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    min-height: 0;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-user {
    align-self: flex-end;
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 4px;
}

.message-assistant {
    align-self: flex-start;
    background: var(--ai-bubble);
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
}

.message-assistant p {
    margin-bottom: 8px;
}

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

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

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

.message-assistant a {
    color: var(--futuriti-blue);
    text-decoration: underline;
    word-break: break-word;
}

.message-assistant a:hover,
.message-assistant a:focus-visible {
    color: var(--futuriti-dark);
}

.message-assistant .chat-h2,
.message-assistant .chat-h3 {
    display: block;
    margin-top: 0.75em;
    margin-bottom: 0.25em;
}

.message-assistant .chat-h2 {
    font-size: 1.05em;
}

.message-assistant .chat-h3 {
    font-size: 1em;
}

.message-assistant hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.75em 0;
}

/* Typing indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--ai-bubble);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    order: 999999;
}

.typing-indicator.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--futuriti-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Welcome message */
.welcome-message {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary);
}

.welcome-message h2 {
    font-family: 'Poppins', sans-serif;
    color: var(--futuriti-blue);
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.welcome-message p {
    font-size: 0.9375rem;
    max-width: 500px;
    margin: 0 auto;
}

/* Input area */
.input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-white);
    position: sticky;
    bottom: 0;
}

.input-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    padding: 11px 16px;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-white);
    resize: none;
    height: 48px;
    min-height: 48px;
    max-height: 120px;
    transition: border-color 0.2s;
    overflow-y: hidden;
}

.chat-input:focus {
    border-color: var(--futuriti-blue);
    outline: none;
}

.chat-input::placeholder {
    color: #999;
}

.send-btn {
    background: var(--futuriti-blue);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.send-btn:hover,
.send-btn:focus-visible {
    background: var(--futuriti-dark);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 100;
    pointer-events: none;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Upload area */
.upload-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

.upload-overlay.visible {
    display: flex;
}

.upload-modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.upload-modal h3 {
    font-family: 'Poppins', sans-serif;
    color: var(--futuriti-blue);
    margin-bottom: 12px;
}

.upload-modal p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.9375rem;
}

.upload-modal input[type="file"] {
    margin: 12px 0;
}

.upload-modal button {
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9375rem;
    min-height: 44px;
}

.upload-btn-primary {
    background: var(--futuriti-blue);
    color: white;
    margin-right: 8px;
}

.upload-btn-secondary {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.alert-banner {
    background-color: #C83939;
    color: #FFF;
    text-align: center;
    padding: 5px;
}

/* Responsive */
@media (min-width: 768px) {
    .chat-header {
        padding: 16px 24px;
    }

    .messages-area {
        padding: 24px;
    }

    .message {
        max-width: 70%;
    }

    .input-area {
        padding: 16px 24px;
    }
}

@media (max-width: 480px) {
    .header-btn span.btn-text {
        display: none;
    }

}

/* High contrast mode support */
@media (forced-colors: active) {
    .message-user,
    .message-assistant {
        border: 1px solid;
    }

    .send-btn {
        border: 1px solid;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .typing-spinner {
        animation-duration: 3s;
    }

    .toast {
        transition: none;
    }

    * {
        scroll-behavior: auto !important;
    }
}
