/* ============================================
   Atelier Amber
   Warm terminal · Deep charcoal · Amber sole accent
   Fonts: Fraunces (display) + JetBrains Mono (all UI)
   ============================================ */

/* === CSS Variables / Design Tokens === */
:root {
    /* ── Backward-compat aliases (templates still use old names) ── */
    --bg-secondary:    #131118;  /* → --bg-surface */
    --bg-card:         #1a1820;  /* → --bg-elevated */
    --bg-card-hover:   #221f2a;  /* → --bg-float */
    --bg-input:        #1a1820;
    --bg-glass:        rgba(13, 11, 15, 0.90);
    --border-color:    rgba(217, 149, 32, 0.09);
    --border-color-hover: rgba(217, 149, 32, 0.20);
    --accent-primary:  #d99520;
    --accent-primary-hover: #f0ac30;
    --accent-primary-glow:  rgba(217, 149, 32, 0.16);
    --accent-secondary: #5aad72;
    --accent-danger:   #d94f4f;
    --accent-warning:  #e07030;
    --accent-info:     #5a90c0;
    --shadow-sm: 0 1px 6px rgba(0, 0, 0, 0.55);
    --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.65);
    --shadow-lg: 0 8px 36px rgba(0, 0, 0, 0.75);
    --shadow-glow: 0 0 22px rgba(217, 149, 32, 0.16);
    --border-radius:    6px;
    --border-radius-sm: 3px;
    --border-radius-lg: 10px;
    --font-family: 'Syne', system-ui, sans-serif;
    --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Background layers — warm-tinted dark */
    --bg-void:     #080709;
    --bg-base:     #0d0b0f;
    --bg-surface:  #131118;
    --bg-elevated: #1a1820;
    --bg-float:    #221f2a;
    --bg-glass:    rgba(13, 11, 15, 0.90);

    /* Amber — the one and only accent */
    --amber:            #d99520;
    --amber-bright:     #f0ac30;
    --amber-dim:        #b88016;
    --amber-pale:       rgba(217, 149, 32, 0.07);
    --amber-glow:       rgba(217, 149, 32, 0.16);
    --amber-glow-hard:  rgba(217, 149, 32, 0.32);

    /* Semantic colours (used sparingly, never decoratively) */
    --green:   #5aad72;
    --red:     #d94f4f;
    --orange:  #e07030;
    --blue:    #5a90c0;

    /* Text — warm-tinted grays, boosted for mono on dark */
    --text-bright:    #faf3e8;
    --text-primary:   #e8dece;
    --text-secondary: #bfbfbf;
    --text-muted:     #c5ab91;
    --text-link:      var(--amber);

    /* Borders — amber-tinted, very subtle */
    --border:        rgba(217, 149, 32, 0.09);
    --border-mid:    rgba(217, 149, 32, 0.20);
    --border-strong: rgba(217, 149, 32, 0.42);

    /* Radius — lean and angular */
    --r-sm: 3px;
    --r:    6px;
    --r-lg: 10px;

    /* Shadows */
    --shadow-sm: 0 1px 6px rgba(0, 0, 0, 0.55);
    --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.65);
    --shadow-lg: 0 8px 36px rgba(0, 0, 0, 0.75);
    --glow:      0 0 22px var(--amber-glow);
    --glow-hard: 0 0 32px var(--amber-glow-hard);

    /* Fonts */
    --font-sans:    'Syne', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --t:      all 0.18s var(--ease);
    --t-slow: all 0.3s var(--ease);
}

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

html {
    font-size: 17px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-mono);
    font-weight: 500;
    background-color: var(--bg-base);
    /* Layered: radial amber spotlight + subtle grid */
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -5%, rgba(217, 149, 32, 0.07) 0%, transparent 65%),
        linear-gradient(rgba(217, 149, 32, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(217, 149, 32, 0.045) 1px, transparent 1px);
    background-size: auto, 56px 56px, 56px 56px;
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Signature amber strip at the very top */
    border-top: 2px solid var(--amber-dim);
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: var(--t);
}

a:hover {
    color: var(--amber-bright);
}

/* === Navbar === */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 56px;
    background: var(--bg-glass);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
}

.navbar-logo {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    text-decoration: none;
}

/* Logo: large italic serif for "RAG", small mono for "Hub" */
.logo-icon {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--amber);
    letter-spacing: -1px;
    line-height: 1;
    font-optical-sizing: auto;
}

.logo-text {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.logo-accent {
    color: var(--text-primary);
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.85rem;
    height: 56px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: var(--t);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--amber-pale);
}

.nav-link.active {
    color: var(--amber-bright);
    border-bottom-color: var(--amber);
    background: var(--amber-pale);
}

.nav-link-chat {
    margin-left: 0.75rem;
    height: auto;
    padding: 0.4rem 1rem;
    background: var(--amber-pale);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    border-bottom: 1px solid var(--border-mid);
}

.nav-link-chat:hover,
.nav-link-chat.active {
    border-color: var(--amber);
    background: var(--amber-glow);
    border-bottom-color: var(--amber);
}

.nav-icon {
    font-size: 0.9rem;
}

/* === Main Content === */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* === Alerts / Flash Messages === */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.1rem;
    border-radius: var(--r);
    margin-bottom: 1.5rem;
    border: 1px solid;
    border-left-width: 3px;
    animation: slideIn 0.25s ease-out;
    font-size: 0.82rem;
}

.alert-success {
    background: rgba(90, 173, 114, 0.08);
    border-color: rgba(90, 173, 114, 0.18);
    border-left-color: var(--green);
    color: #7ac890;
}

.alert-error {
    background: rgba(217, 79, 79, 0.08);
    border-color: rgba(217, 79, 79, 0.18);
    border-left-color: var(--red);
    color: #d97070;
}

.alert-info {
    background: var(--amber-pale);
    border-color: var(--border-mid);
    border-left-color: var(--amber);
    color: var(--amber-bright);
}

.alert-message {
    flex: 1;
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.55;
    transition: var(--t);
    padding: 0.15rem;
    line-height: 1;
}

.alert-close:hover {
    opacity: 1;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    font-style: italic;
    color: var(--text-bright);
    line-height: 1.2;
    letter-spacing: -0.5px;
    font-optical-sizing: auto;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.35rem;
    letter-spacing: 0.03em;
}

.page-actions {
    display: flex;
    gap: 0.625rem;
    flex-shrink: 0;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--t);
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.btn-primary {
    background: var(--amber);
    color: var(--bg-void);
    border-color: var(--amber);
}

.btn-primary:hover {
    background: var(--amber-bright);
    color: var(--bg-void);
    border-color: var(--amber-bright);
    box-shadow: var(--glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-mid);
}

.btn-secondary:hover {
    background: var(--bg-float);
    border-color: var(--border-strong);
    color: var(--text-bright);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--amber-pale);
}

.btn-danger {
    background: rgba(217, 79, 79, 0.08);
    color: #d07070;
    border-color: rgba(217, 79, 79, 0.2);
}

.btn-danger:hover {
    background: rgba(217, 79, 79, 0.16);
    border-color: rgba(217, 79, 79, 0.4);
    color: #e08080;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.32rem 0.7rem;
    font-size: 0.75rem;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-surface);
    border-radius: var(--r-lg);
    border: 1px dashed var(--border-mid);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1.25rem;
    opacity: 0.4;
    display: block;
}

.empty-state h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    font-style: italic;
    color: var(--text-bright);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto 1.5rem;
    font-size: 0.82rem;
    line-height: 1.7;
}

.empty-state-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* === Documents Grid === */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

.document-card {
    background: var(--bg-surface);
    border-radius: var(--r);
    border: 1px solid var(--border);
    transition: var(--t-slow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.document-card:hover {
    border-color: var(--border-mid);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.document-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem 0;
}

.document-type-badge {
    font-size: 0.73rem;
    font-weight: 700;
    padding: 0.18rem 0.55rem;
    border-radius: var(--r-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: var(--font-mono);
}

.badge-file {
    background: rgba(90, 144, 192, 0.10);
    color: #7ab0d8;
    border: 1px solid rgba(90, 144, 192, 0.18);
}

.badge-url {
    background: var(--amber-pale);
    color: var(--amber);
    border: 1px solid var(--border);
}

.document-status {
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.status-pending   { color: var(--orange); }
.status-processing { color: var(--blue); }
.status-indexed   { color: var(--green); }
.status-error     { color: var(--red); }

.document-card-body {
    padding: 0.875rem 1rem;
    flex: 1;
}

.document-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    line-height: 1.45;
    word-break: break-word;
    color: var(--text-bright);
}

.document-meta {
    margin-bottom: 0.4rem;
}

.document-source-link {
    font-size: 0.78rem;
    color: var(--amber);
    word-break: break-all;
}

.document-filename {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.document-mime {
    display: inline-block;
    font-size: 0.73rem;
    padding: 0.1rem 0.4rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--r-sm);
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    border: 1px solid var(--border);
}

.document-error {
    font-size: 0.75rem;
    color: #d07070;
    background: rgba(217, 79, 79, 0.08);
    padding: 0.4rem 0.6rem;
    border-radius: var(--r-sm);
    margin-bottom: 0.4rem;
    border-left: 2px solid var(--red);
}

.document-stats {
    display: flex;
    gap: 1rem;
    margin-top: 0.625rem;
}

.stat {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.document-card-footer {
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.delete-form {
    margin: 0;
}

/* === Admin grid (client cards, etc.) === */
.clients-grid,
.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.client-card,
.profile-card-admin {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 1.25rem;
    transition: var(--t-slow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.client-card:hover,
.profile-card-admin:hover {
    border-color: var(--border-mid);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.client-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.client-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-bright);
}

.client-status-badge {
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.18rem 0.55rem;
    border-radius: var(--r-sm);
    flex-shrink: 0;
}

.status-active {
    background: rgba(90, 173, 114, 0.1);
    color: var(--green);
    border: 1px solid rgba(90, 173, 114, 0.2);
}

.status-inactive {
    background: rgba(80, 72, 64, 0.2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.client-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.client-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: auto;
    flex-wrap: wrap;
}

/* === Info Grid (client show page) === */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 1.25rem;
}

.info-card-label {
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--amber-dim);
    margin-bottom: 0.5rem;
}

.info-card-value {
    font-size: 0.85rem;
    color: var(--text-bright);
    word-break: break-all;
    line-height: 1.5;
}

.info-card-value code {
    font-family: var(--font-mono);
    background: var(--bg-elevated);
    padding: 0.5rem 0.75rem;
    border-radius: var(--r-sm);
    display: block;
    font-size: 0.78rem;
    color: var(--amber-bright);
    border: 1px solid var(--border-mid);
    word-break: break-all;
}

/* === Section Headers (admin) === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.section-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--amber-dim);
}

/* === Form Card === */
.form-card {
    background: var(--bg-surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    padding: 2rem;
    max-width: 600px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.required {
    color: var(--red);
}

.form-input,
textarea.form-input,
select.form-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    transition: var(--t);
    outline: none;
    line-height: 1.5;
}

select.form-input {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a8070' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.5rem;
}

.form-input:focus {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-glow);
}

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

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    line-height: 1.5;
}

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.form-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--amber);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label {
    font-size: 0.82rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

/* === File Upload === */
.file-upload-area {
    position: relative;
    border: 2px dashed var(--border-mid);
    border-radius: var(--r);
    padding: 2.5rem 2rem;
    text-align: center;
    transition: var(--t);
    cursor: pointer;
    background: var(--bg-elevated);
}

.file-upload-area:hover,
.file-upload-area.dragover {
    border-color: var(--amber);
    background: var(--amber-pale);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.file-upload-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.file-upload-link {
    color: var(--amber);
    font-weight: 700;
}

.file-upload-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.file-upload-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
}

.file-preview-name {
    font-weight: 700;
    color: var(--amber);
}

.file-preview-size {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* === Chat Container === */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px - 4rem);
    max-width: 820px;
    margin: 0 auto;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0 0.875rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

.chat-header > div {
    flex: 1;
    text-align: center;
}

.chat-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    font-style: italic;
    color: var(--text-bright);
    letter-spacing: -0.3px;
    font-optical-sizing: auto;
}

.chat-subtitle {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 0.2rem;
    letter-spacing: 0.04em;
}

.btn-clear-chat {
    padding: 0.32rem 0.75rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--t);
    flex-shrink: 0;
}

.btn-clear-chat:hover {
    color: var(--red);
    border-color: rgba(217, 79, 79, 0.35);
    background: rgba(217, 79, 79, 0.06);
}

/* === Chat Messages Area === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-mid) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-mid);
    border-radius: 2px;
}

/* === Welcome State === */
.chat-welcome {
    text-align: center;
    padding: 3.5rem 2rem;
    margin: auto;
    max-width: 540px;
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    opacity: 0.45;
    display: block;
    animation: pulse 3s ease-in-out infinite;
}

.chat-welcome h2 {
    font-family: var(--font-display);
    font-size: 2.1rem;
    font-weight: 700;
    font-style: italic;
    color: var(--text-bright);
    margin-bottom: 0.75rem;
    letter-spacing: -0.5px;
    font-optical-sizing: auto;
    line-height: 1.15;
}

.chat-welcome p {
    color: var(--text-secondary);
    max-width: 440px;
    margin: 0 auto 2rem;
    font-size: 0.82rem;
    line-height: 1.75;
}

/* Decorative rule under the welcome text */
.chat-welcome p::after {
    content: '';
    display: block;
    width: 40px;
    height: 1px;
    background: var(--amber-dim);
    margin: 1.25rem auto 0;
    opacity: 0.6;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

/* Terminal-style suggestion chips: each chip looks like a CLI command */
.suggestion-chip {
    padding: 0.45rem 0.9rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--t);
    text-align: left;
}

.suggestion-chip::before {
    content: '› ';
    color: var(--amber-dim);
    font-weight: 700;
}

.suggestion-chip:hover {
    background: var(--bg-elevated);
    border-color: var(--amber);
    color: var(--amber-bright);
    transform: translateX(3px);
}

/* === Profile Picker === */
.profile-picker {
    text-align: center;
    padding: 3rem 2rem;
    margin: auto;
}

.profile-picker-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
    display: block;
}

.profile-picker h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    font-style: italic;
    color: var(--text-bright);
    margin-bottom: 0.5rem;
}

.profile-picker p {
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto 2rem;
    font-size: 0.82rem;
}

.profile-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.profile-card {
    padding: 0.875rem 1.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: var(--t);
    min-width: 130px;
    text-align: center;
}

.profile-card:hover {
    background: var(--bg-elevated);
    border-color: var(--amber);
    color: var(--amber-bright);
    transform: translateY(-2px);
    box-shadow: var(--glow);
}

/* === In-message links === */
.chat-link {
    color: var(--amber);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(217, 149, 32, 0.4);
    word-break: break-all;
}

.chat-link:hover {
    color: var(--amber-bright);
    opacity: 1;
}

/* === Closure CTA === */
.chat-closure-cta {
    display: flex;
    justify-content: center;
    padding: 1rem 0 0.5rem;
}

.btn-closure-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    background: var(--amber);
    color: var(--bg-void);
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    transition: var(--t);
    box-shadow: var(--glow);
}

.btn-closure-cta:hover {
    background: var(--amber-bright);
    color: var(--bg-void);
    transform: translateY(-2px);
    box-shadow: var(--glow-hard);
}

/* === Chat Message Bubbles === */
.chat-message {
    display: flex;
    gap: 0.75rem;
    animation: fadeInUp 0.22s ease-out;
}

.chat-message-user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--r-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-mid);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
    flex-shrink: 0;
    color: var(--text-muted);
}

.chat-message-user .message-avatar {
    background: var(--amber-pale);
    border-color: var(--amber-dim);
    color: var(--amber);
}

.chat-message-assistant .message-avatar {
    opacity: 0.65;
}

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

.message-text {
    padding: 0.875rem 1.1rem;
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.8;
}

/* User bubble: amber on dark — warm and distinct */
.chat-message-user .message-text {
    background: var(--amber);
    color: var(--bg-void);
    font-weight: 500;
    border-bottom-right-radius: 1px;
    text-align: right;
}

/* Assistant bubble: surface with left amber stripe — like a pull-quote */
.chat-message-assistant .message-text {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--amber-dim);
    border-bottom-left-radius: 1px;
    color: var(--text-primary);
}

.message-text p + p {
    margin-top: 0.6rem;
}

.message-text ul,
.message-text ol {
    padding-left: 1.25rem;
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.message-text code {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.1rem 0.35rem;
    border-radius: var(--r-sm);
    font-size: 0.87em;
    color: var(--amber-bright);
    font-family: var(--font-mono);
}

.message-error {
    background: rgba(217, 79, 79, 0.08) !important;
    border-color: rgba(217, 79, 79, 0.18) !important;
    border-left-color: var(--red) !important;
    color: #d07070 !important;
}

/* === Message Sources — styled like academic footnotes === */
.message-sources {
    margin-top: 0.75rem;
    background: var(--bg-void);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.sources-header {
    padding: 0.45rem 0.875rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber-dim);
    border-bottom: 1px solid var(--border);
    background: rgba(217, 149, 32, 0.03);
}

.source-item {
    display: flex;
    gap: 0.625rem;
    padding: 0.6rem 0.875rem;
    border-bottom: 1px solid var(--border);
    transition: var(--t);
}

.source-item:last-child {
    border-bottom: none;
}

.source-item:hover {
    background: rgba(255, 255, 255, 0.015);
}

.source-badge {
    flex-shrink: 0;
    font-size: 0.85rem;
    opacity: 0.7;
}

.source-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.source-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.source-link,
.source-ref {
    font-size: 0.75rem;
    color: var(--amber);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-ref {
    color: var(--text-muted);
}

.source-score {
    font-size: 0.73rem;
    color: var(--text-muted);
}

.source-excerpt {
    margin-top: 0.35rem;
    padding: 0.35rem 0.55rem;
    background: var(--bg-elevated);
    border-left: 2px solid var(--amber-dim);
    border-radius: var(--r-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.5;
}

/* === Loading Animation — amber dots === */
.loading-dots {
    display: flex;
    gap: 5px;
    padding: 0.875rem 1.1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--amber-dim);
    border-radius: var(--r-sm);
    width: fit-content;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--amber-dim);
    animation: dotPulse 1.4s infinite ease-in-out both;
}

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

/* === Chat Input === */
.chat-input-area {
    flex-shrink: 0;
    padding: 0.875rem 0;
}

.chat-form {
    width: 100%;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.625rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-mid);
    border-radius: var(--r);
    padding: 0.6rem 0.75rem;
    transition: var(--t);
}

.chat-input-wrapper:focus-within {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-glow);
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    resize: none;
    line-height: 1.55;
    max-height: 150px;
}

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

/* Send button: amber square, matches the brand language */
.chat-send-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    border: 1px solid var(--amber);
    background: var(--amber);
    color: var(--bg-void);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--t);
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--amber-bright);
    border-color: var(--amber-bright);
    box-shadow: var(--glow);
    transform: scale(1.06);
}

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

/* === Login Page === */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px - 4rem);
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-lg);
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    font-style: italic;
    color: var(--text-bright);
    margin-bottom: 0.35rem;
}

.login-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

/* === Animations === */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { opacity: 0.45; transform: scale(1); }
    50%       { opacity: 0.65; transform: scale(1.04); }
}

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

/* === Chat profile select (in header) === */
.chat-profile-select {
    padding: 0.35rem 2rem 0.35rem 0.65rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: var(--t);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%238a8070' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    max-width: 160px;
}

.chat-profile-select:focus {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-glow);
}

.chat-profile-select option {
    background: var(--bg-float);
    color: var(--text-primary);
}

/* === Pre / code blocks === */
pre {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--amber-dim);
    border-radius: var(--r-sm);
    padding: 0.875rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

/* === Data display box (API key, URL, etc.) === */
.data-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    padding: 0.7rem 0.875rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--amber-bright);
    word-break: break-all;
    line-height: 1.5;
    letter-spacing: 0.02em;
    margin-bottom: 1rem;
}

/* === Responsive === */
@media (max-width: 768px) {
    .navbar {
        padding: 0 1rem;
    }

    .navbar-menu {
        gap: 0;
    }

    /* Icon-only nav on mobile */
    .nav-link {
        padding: 0 0.5rem;
        font-size: 0;
        letter-spacing: 0;
    }

    .nav-icon {
        font-size: 1.1rem;
    }

    .main-content {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .documents-grid,
    .clients-grid,
    .profiles-grid {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .form-card {
        padding: 1.25rem;
    }

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

    .welcome-suggestions {
        flex-direction: column;
        align-items: center;
    }

    .chat-container {
        height: calc(100vh - 56px - 2rem);
    }

    .chat-welcome {
        padding: 2rem 1rem;
    }

    .chat-welcome h2 {
        font-size: 1.6rem;
    }
}
