/* ============================================================
   Bouwcenter Concordia — Offerte Tool
   "Dutch Industrial Precision" — enterprise tool aesthetic
   ============================================================ */

/* ---- Fonts ---- */
@font-face {
    font-family: 'MuseoSans';
    src: url('../assets/fonts/MuseoSans-300.woff2') format('woff2');
    font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'MuseoSans';
    src: url('../assets/fonts/MuseoSans-500.woff2') format('woff2');
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'MuseoSans';
    src: url('../assets/fonts/MuseoSans-700.woff2') format('woff2');
    font-weight: 700; font-style: normal; font-display: swap;
}

/* ---- Tokens ---- */
:root {
    --blue-900: #002244;
    --blue-800: #003366;
    --blue-700: #004c99;
    --blue-600: #0a5cad;
    --blue-500: #297acc;
    --blue-400: #5a9cd9;
    --blue-200: #b3d1f0;
    --blue-100: #dde9f6;
    --blue-50: #f0f5fb;

    --green-700: #79b442;
    --green-600: #8cc34f;
    --green-500: #9fd162;
    --green-100: #eaf5dc;

    --yellow-600: #ffbe00;
    --red-600: #d93025;
    --red-100: #fce8e6;

    --ink: #1a1a2e;
    --ink-secondary: #44475a;
    --ink-muted: #8892a4;
    --ink-faint: #b0b8c8;

    --surface: #ffffff;
    --surface-raised: #f8f9fb;
    --surface-sunken: #f1f3f6;
    --surface-overlay: rgba(0, 0, 0, 0.5);

    --border: #e2e5ea;
    --border-light: #eef0f3;

    --font: 'MuseoSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --header-h: 3.25rem;
    --sidebar-w: clamp(15rem, 17vw, 20rem);

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    height: 100%;
}

body {
    font-family: var(--font);
    font-weight: 500;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--surface-sunken);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---- Header ---- */
.header {
    background: var(--blue-700);
    flex-shrink: 0;
    z-index: 100;
    position: relative;
}

.header-inner {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
}

.header-logo { display: flex; align-items: center; flex-shrink: 0; }

.header-logo .logo {
    height: 1.5rem;
    width: auto;
    filter: brightness(0) invert(1);
    opacity: 0.95;
}

.header-separator {
    width: 1px;
    height: 1.25rem;
    background: rgba(255,255,255,0.2);
    flex-shrink: 0;
}

.header-title { flex: 1; }
.header-title h1 {
    font-size: 0.875rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green-500);
    box-shadow: 0 0 6px var(--green-500);
    animation: statusPulse 3s ease-in-out infinite;
}

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

.status-text {
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.6);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.header-accent {
    height: 3px;
    background: linear-gradient(90deg, var(--yellow-600) 0%, var(--green-700) 50%, var(--blue-500) 100%);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 0.25rem;
    transition: all 200ms var(--ease);
}
.sidebar-toggle:hover { color: white; background: rgba(255,255,255,0.1); }

/* ---- App Layout ---- */
.app-layout {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--blue-900);
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    margin-bottom: 1.25rem;
}

.sidebar-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}
.sidebar-heading svg { opacity: 0.5; stroke: rgba(255,255,255,0.4); }

.sidebar .form-group { margin-bottom: 0.875rem; }

.sidebar .form-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.25rem;
}

.sidebar .form-input {
    width: 100%;
    padding: 0.5rem 0.625rem;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0.375rem;
    outline: none;
    transition: all 200ms var(--ease);
}
.sidebar .form-input:hover { border-color: rgba(255,255,255,0.18); }
.sidebar .form-input:focus {
    border-color: var(--blue-500);
    background: rgba(255,255,255,0.1);
    box-shadow: 0 0 0 2px rgba(41,122,204,0.2);
}
.sidebar .form-input::placeholder { color: rgba(255,255,255,0.25); font-weight: 300; }

.input-with-suffix {
    position: relative;
}
.input-with-suffix .form-input { padding-right: 3.5rem; }
.input-suffix {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.3);
    font-weight: 500;
    pointer-events: none;
}

.sidebar .btn-ghost {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
}
.sidebar .btn-ghost:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
    color: white;
    border-color: rgba(255,255,255,0.2);
}

.sidebar-brand {
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 0.625rem;
}
.sidebar-brand-icon { width: 1.5rem; height: 1.5rem; opacity: 0.4; }
.sidebar-brand-name { font-size: 0.75rem; font-weight: 700; color: rgba(255,255,255,0.4); }
.sidebar-brand-version { font-size: 0.625rem; color: rgba(255,255,255,0.2); }

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--surface);
    position: relative;
}

/* ---- Chat Container ---- */
.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: clamp(1rem, 3vw, 2rem) clamp(1.25rem, 4vw, 3rem);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    scroll-behavior: smooth;
    background:
        radial-gradient(ellipse at 0% 0%, rgba(0,76,153,0.02) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(121,180,66,0.02) 0%, transparent 50%),
        var(--surface);
}

/* ---- Welcome ---- */
.welcome-message {
    margin: auto;
    padding: 2rem;
    animation: welcomeIn 600ms var(--ease) both;
}

@keyframes welcomeIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.welcome-card {
    max-width: 28rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow:
        0 1px 3px rgba(0,0,0,0.04),
        0 8px 32px rgba(0,0,0,0.04);
}

.welcome-logo {
    margin-bottom: 1.25rem;
}

.welcome-logo-img {
    width: 3rem;
    height: 3rem;
}

.welcome-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0.25rem;
    letter-spacing: -0.01em;
}

.welcome-subtitle {
    font-size: 0.8125rem;
    color: var(--ink-muted);
    font-weight: 300;
}

.welcome-divider {
    width: 2rem;
    height: 2px;
    background: var(--blue-700);
    margin: 1.5rem auto;
    border-radius: 1px;
}

.welcome-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: left;
}

.welcome-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: welcomeIn 500ms var(--ease) both;
}
.welcome-step:nth-child(1) { animation-delay: 150ms; }
.welcome-step:nth-child(2) { animation-delay: 250ms; }
.welcome-step:nth-child(3) { animation-delay: 350ms; }

.welcome-step-num {
    flex-shrink: 0;
    width: 1.375rem;
    height: 1.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-50);
    color: var(--blue-700);
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 0.25rem;
}

.welcome-step p {
    font-size: 0.8125rem;
    color: var(--ink-secondary);
    font-weight: 500;
    line-height: 1.4;
    padding-top: 0.0625rem;
}

/* ---- Messages ---- */
.message {
    display: flex;
    gap: 0.625rem;
    max-width: min(88%, 52rem);
    animation: msgIn 350ms var(--ease) both;
}

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

.message + .message { margin-top: 1rem; }

.message-user {
    flex-direction: row-reverse;
    margin-left: auto;
    max-width: min(72%, 40rem);
}

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

.message-avatar {
    width: 1.625rem;
    height: 1.625rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.625rem;
    font-weight: 700;
    margin-top: 0.1875rem;
    letter-spacing: 0.02em;
}

.message-user .message-avatar {
    background: var(--blue-100);
    color: var(--blue-700);
}

.message-assistant .message-avatar {
    background: var(--blue-700);
    color: white;
}

.message-bubble {
    padding: 0.75rem 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.55;
    font-size: 0.875rem;
}

.message-user .message-bubble {
    background: var(--blue-700);
    color: white;
    border-radius: 0.75rem 0.75rem 0.25rem 0.75rem;
}

.message-assistant .message-bubble {
    background: var(--surface-raised);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 0.75rem 0.75rem 0.75rem 0.25rem;
}

/* Markdown in messages */
.message-bubble h3 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--blue-700);
    margin-top: 0.875rem;
    margin-bottom: 0.25rem;
    letter-spacing: -0.005em;
}
.message-user .message-bubble h3 { color: rgba(255,255,255,0.85); }
.message-bubble h3:first-child { margin-top: 0; }

.message-bubble p {
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
}
.message-bubble p:last-child { margin-bottom: 0; }

.message-bubble ul {
    margin: 0.375rem 0;
    padding-left: 1.25rem;
    font-size: 0.8125rem;
}
.message-bubble li { margin-bottom: 0.125rem; }

.message-bubble strong { font-weight: 700; }
.message-bubble em { font-style: italic; color: var(--ink-muted); }
.message-user .message-bubble em { color: rgba(255,255,255,0.6); }

.message-bubble hr {
    border: none;
    height: 1px;
    background: var(--border-light);
    margin: 0.75rem 0;
}
.message-user .message-bubble hr { background: rgba(255,255,255,0.15); }

.message-bubble code {
    background: rgba(0,0,0,0.04);
    padding: 0.1em 0.3em;
    border-radius: 0.25rem;
    font-size: 0.85em;
}

.message-download {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

/* ---- Loading ---- */
.loading-indicator {
    padding: 0.75rem 0;
    max-width: 20rem;
    animation: msgIn 300ms var(--ease) both;
}

.loading-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.loading-bar-fill {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--blue-700), var(--blue-500));
    border-radius: 2px;
    animation: loadingSlide 1.5s ease-in-out infinite;
}

@keyframes loadingSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.loading-text {
    font-size: 0.75rem;
    color: var(--ink-muted);
    font-weight: 500;
}

/* ---- Input Area ---- */
.input-area {
    border-top: 1px solid var(--border);
    padding: 0.875rem clamp(1.25rem, 4vw, 3rem);
    background: var(--surface);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ink);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    resize: none;
    min-height: 2.5rem;
    max-height: 10rem;
    outline: none;
    transition: all 200ms var(--ease);
    line-height: 1.5;
}

.chat-input:hover { border-color: var(--ink-faint); }
.chat-input:focus {
    border-color: var(--blue-500);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(0,76,153,0.08);
}
.chat-input::placeholder { color: var(--ink-faint); font-weight: 300; }

.send-btn {
    flex-shrink: 0;
    height: fit-content;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 700;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 200ms var(--ease);
    text-decoration: none;
    line-height: 1.5;
    white-space: nowrap;
    user-select: none;
}

.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-action {
    background: var(--green-700);
    color: white;
    border-color: var(--green-700);
}
.btn-action:hover:not(:disabled) {
    background: var(--green-600);
    box-shadow: 0 2px 8px rgba(121,180,66,0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--ink-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-raised);
    border-color: var(--ink-faint);
    color: var(--ink);
}

.btn-full { width: 100%; }

.btn-download {
    background: var(--blue-700);
    color: white;
    border-color: var(--blue-700);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
}
.btn-download:hover:not(:disabled) {
    background: var(--blue-600);
    box-shadow: 0 2px 8px rgba(0,76,153,0.2);
}

/* ---- Error ---- */
.error-message {
    background: var(--red-100);
    border: 1px solid rgba(217,48,37,0.15);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--red-600);
    font-size: 0.8125rem;
    animation: msgIn 300ms var(--ease) both;
}
.error-message strong { display: block; margin-bottom: 0.125rem; font-weight: 700; }

/* ---- Overlay ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--surface-overlay);
    backdrop-filter: blur(3px);
    z-index: 49;
}
.sidebar-overlay.active { display: block; }

/* ---- Responsive ---- */
@media (max-width: 55rem) {
    .sidebar-toggle { display: flex; }
    .header-status { display: none; }

    .sidebar {
        position: fixed;
        top: calc(var(--header-h) + 3px);
        left: 0;
        bottom: 0;
        z-index: 50;
        width: 17rem;
        transform: translateX(-100%);
        transition: transform 300ms var(--ease);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }
    .sidebar.open { transform: translateX(0); }

    .message { max-width: 100%; }
    .message-user { max-width: 85%; }
}

@media (max-width: 35rem) {
    .send-btn span { display: none; }
    .send-btn { padding: 0.5rem; }
    .header-logo .logo { height: 1.25rem; }
    .header-separator { display: none; }
}

/* ---- Scrollbars ---- */
.chat-container::-webkit-scrollbar { width: 5px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.chat-container::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

.sidebar::-webkit-scrollbar { width: 0; }

/* ---- Selection ---- */
::selection { background: var(--blue-100); color: var(--blue-900); }
