/* ============================================
   Lars Laj Assistant — Brand Design System
   Colors: #d9261c (red), #1f1917 (charcoal)
   Font: Poppins
   ============================================ */

:root {
    --brand-red: #d9261c;
    --brand-red-dark: #b81f17;
    --brand-red-light: #fef2f1;
    --brand-charcoal: #1f1917;
    --brand-charcoal-light: #3a3230;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --shadow-sm: 0 1px 3px rgba(31, 25, 23, 0.06);
    --shadow-md: 0 4px 12px rgba(31, 25, 23, 0.08);
    --shadow-lg: 0 8px 30px rgba(31, 25, 23, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

/* ---- Global ---- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
    color: var(--brand-charcoal);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-card-header {
    background: var(--brand-charcoal);
    padding: 32px 40px 28px;
    text-align: center;
}

.login-card-header img {
    height: 36px;
    margin-bottom: 16px;
    filter: brightness(0) invert(1);
}

.login-card-header h3 {
    color: white;
    font-size: 1rem;
    font-weight: 400;
    margin: 0;
    opacity: 0.7;
}

.login-card-body {
    padding: 32px 40px 40px;
}

.login-card-body .form-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
    margin-bottom: 6px;
}

.login-card-body .form-control {
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.login-card-body .form-control:focus {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(217, 38, 28, 0.1);
}

.btn-login {
    background: var(--brand-red);
    border: none;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    padding: 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
    width: 100%;
}

.btn-login:hover {
    background: var(--brand-red-dark);
    color: white;
}

.btn-login:active {
    transform: scale(0.98);
}

/* ---- Chat Page ---- */
.chat-wrapper {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: white;
}

@media (min-width: 1024px) {
    .chat-wrapper {
        margin: 16px auto;
        height: calc(100vh - 32px);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-lg);
        overflow: hidden;
    }
}

/* Header */
.chat-header {
    padding: 0 24px;
    height: 64px;
    border-bottom: 1px solid var(--gray-200);
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-header-brand img {
    height: 28px;
}

.chat-header-brand .brand-divider {
    width: 1px;
    height: 24px;
    background: var(--gray-300);
}

.chat-header-brand span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-600);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#newChatButton {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--gray-300);
    background: white;
    color: var(--brand-charcoal);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

#newChatButton:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
    background: var(--brand-red-light);
}

.status-indicator {
    display: flex;
    align-items: center;
    font-size: 0.78rem;
    color: var(--gray-500);
    font-weight: 400;
}

.status-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 6px;
}

#tokenUsage {
    font-variant-numeric: tabular-nums;
}

#tokenUsage svg {
    opacity: 0.5;
}

/* Chat Container */
.chat-container {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: var(--gray-50);
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Welcome Message */
.welcome-area {
    text-align: center;
    padding: 40px 20px;
}

.welcome-area h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--brand-charcoal);
    margin-bottom: 8px;
}

.welcome-area p {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* Messages */
.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    animation: messageIn 0.25s ease-out;
}

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

.message-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    color: var(--gray-400);
}

.message-content {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: var(--radius-lg);
    font-size: 0.92rem;
    line-height: 1.6;
    position: relative;
}

.message-user {
    align-items: flex-end;
}

.message-user .message-content {
    background: var(--brand-red);
    color: white;
    border-bottom-right-radius: 6px;
}

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

.message-assistant .message-content {
    background: white;
    color: var(--brand-charcoal);
    border-bottom-left-radius: 6px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

/* Chat Footer */
.chat-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--gray-200);
    background: white;
    flex-shrink: 0;
}

/* Quick Suggestions Strip */
.quick-suggestions {
    display: flex;
    gap: 6px;
    padding-bottom: 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.quick-suggestions::-webkit-scrollbar {
    display: none;
}

.quick-suggestion-btn {
    flex-shrink: 0;
    background: white;
    border: 1px solid var(--gray-200);
    color: var(--gray-600);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.quick-suggestion-btn:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
    background: var(--brand-red-light);
}

.input-group-chat {
    background: var(--gray-50);
    border-radius: var(--radius-full);
    padding: 4px 4px 4px 20px;
    border: 1.5px solid var(--gray-300);
    transition: border-color 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
}

.input-group-chat:focus-within {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(217, 38, 28, 0.08);
    background: white;
}

#userInput {
    background: transparent;
    border: none;
    box-shadow: none;
    font-size: 0.92rem;
    flex: 1;
    font-family: inherit;
    color: var(--brand-charcoal);
}

#userInput:focus {
    outline: none;
}

#userInput::placeholder {
    color: var(--gray-400);
}

#sendButton {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--brand-red);
    color: white;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

#sendButton:hover {
    background: var(--brand-red-dark);
}

#sendButton:active {
    transform: scale(0.92);
}

#sendButton svg {
    width: 18px;
    height: 18px;
}

/* Typing Indicator */
.typing {
    display: none;
    align-items: center;
    gap: 2px;
    padding: 12px 18px;
    background: white;
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 6px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    width: fit-content;
    margin-bottom: 16px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--brand-red);
    opacity: 0.4;
    border-radius: 50%;
    margin-right: 3px;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; margin-right: 0; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.3; }
    40% { transform: scale(1.1); opacity: 1; }
}


/* ---- Markdown Content ---- */
.message-content p:last-child {
    margin-bottom: 0;
}

.message-content img {
    max-width: 280px;
    max-height: 280px;
    border-radius: var(--radius-md);
    object-fit: contain;
    display: block;
    margin: 12px 0;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    background: var(--gray-100);
    padding: 6px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.message-content img:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.message-content img.img-expanded {
    max-width: 100%;
    max-height: 600px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    background: white;
}

.message-content pre {
    background: var(--brand-charcoal);
    color: #f0eded;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 10px 0;
    font-size: 0.85rem;
}

.message-content code {
    background: rgba(31, 25, 23, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.85em;
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

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

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.88rem;
}

.message-content th, .message-content td {
    border: 1px solid var(--gray-300);
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.message-user .message-content a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message-assistant .message-content a {
    color: var(--brand-red);
    text-decoration: none;
}

.message-assistant .message-content a:hover {
    text-decoration: underline;
}

.message-assistant .message-content blockquote {
    border-left: 3px solid var(--brand-red);
    padding-left: 12px;
    color: var(--gray-600);
    margin: 10px 0;
}

.message-user .message-content code {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(31, 25, 23, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    transform: scale(0.95) translateY(8px);
    transition: transform 0.2s;
}

.modal-overlay.active .modal-dialog {
    transform: scale(1) translateY(0);
}

.modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--brand-red-light);
    color: var(--brand-red);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--brand-charcoal);
    margin: 0 0 8px;
}

.modal-text {
    font-size: 0.88rem;
    color: var(--gray-600);
    margin: 0 0 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    border: none;
}

.modal-btn-cancel {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-btn-cancel:hover {
    background: var(--gray-200);
}

.modal-btn-confirm {
    background: var(--brand-red);
    color: white;
}

.modal-btn-confirm:hover {
    background: var(--brand-red-dark);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .chat-header {
        padding: 0 16px;
        height: 56px;
    }

    .chat-header-brand span {
        display: none;
    }

    .chat-header-brand .brand-divider {
        display: none;
    }

    .chat-container {
        padding: 16px;
    }

    .chat-footer {
        padding: 12px 16px 16px;
    }

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

    #tokenUsage {
        display: none;
    }

    .suggestion-btn {
        font-size: 0.78rem;
        padding: 6px 12px;
    }
}
