/* ============================================
   HONESTBONE MEDICAL THEME
   Professional medical interface styling
   ============================================ */

/* Variables - Dark Theme */
:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #06b6d4;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --navy: #002147;
    --teal: #476a7a;
    --chat-focus-teal: #00b8c2;

    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
.header {
    background: linear-gradient(to right, #2e4150, #476a7a);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    font-size: 2.5rem;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.15s ease;
    border-radius: 8px;
    overflow: hidden;
}

.logo-link:hover {
    opacity: 0.85;
}

.logo-image {
    height: 60px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    mix-blend-mode: lighten;
}

/* Navigation */
.main-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.nav-link {
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    padding: 0.5rem 1.125rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.nav-link:hover {
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
}

.nav-link.active {
    color: white;
    background: var(--navy);
    border-color: var(--navy);
}

/* Page containers */
.page-container {
    animation: pageIn 0.2s ease;
}

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

/* Main Content */
.main-content {
    flex: 1;
    padding: 3rem 0;
}

/* Main query section - full width */
.main-query-section {
    margin-bottom: 2rem;
}

/* Card Styles */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card-header i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
}

.card-body {
    padding: 1.5rem;
}

/* Chat Section */
.chat-messages {
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.welcome-message i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    color: #476a7a;
}

.welcome-logo {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    mix-blend-mode: lighten;
}

.welcome-message h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    font-weight: 600;
}

.welcome-message p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #8a9aa4;
    margin-bottom: 2rem;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    text-wrap: balance;
}

.example-queries {
    margin-top: 2rem;
    text-align: left;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.example-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.example-query {
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.example-query:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateX(4px);
}

.chat-message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

.chat-message.user {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 80%;
    min-width: 0;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    line-height: 1.5;
}

.chat-message.user .message-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chat-message.assistant {
    flex-direction: column;
}

.chat-message.assistant .message-bubble {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-top-left-radius: 0.25rem;
}

/* Structured response sections */
.chat-header {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.chat-header p:last-child { margin-bottom: 0; }

.chat-footer {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}
.chat-footer p:last-child { margin-bottom: 0; }

/* Suggestion pills */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.suggestion-pill {
    background: var(--teal);
    border: 1px solid var(--teal);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    text-align: left;
    line-height: 1.3;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.suggestion-pill:hover {
    background: #3a5766;
    border-color: #3a5766;
}

/* Markdown Content in Assistant Messages */
.markdown-content {
    line-height: 1.7;
}

.markdown-content p {
    margin-bottom: 0.75rem;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.markdown-content h3 {
    font-size: 1rem;
}

.markdown-content h4 {
    font-size: 0.9375rem;
}

.markdown-content strong {
    color: #93c5fd;
    font-weight: 600;
}

.markdown-content em {
    color: var(--text-secondary);
    font-style: italic;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.markdown-content li {
    margin-bottom: 0.25rem;
}

/* Markdown Tables */
.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.8125rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.markdown-content thead {
    background: var(--primary-dark);
}

.markdown-content thead th {
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: white;
    font-size: 0.8125rem;
    white-space: nowrap;
    border-bottom: 2px solid var(--primary-color);
}

.markdown-content tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.markdown-content tbody tr:hover {
    background: var(--bg-tertiary);
}

.markdown-content tbody tr:last-child {
    border-bottom: none;
}

.markdown-content tbody td {
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    vertical-align: top;
}

.markdown-content tbody td:first-child {
    font-weight: 500;
    color: #93c5fd;
}

/* Responsive table wrapper */
.markdown-content .table-wrapper {
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: var(--radius-sm);
}

/* Code blocks */
.markdown-content code {
    background: var(--bg-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.8125rem;
    color: var(--secondary-color);
}

.markdown-content pre {
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0.75rem 0;
}

.markdown-content pre code {
    padding: 0;
    background: none;
}

/* Blockquotes */
.markdown-content blockquote {
    border-left: 3px solid var(--primary-color);
    padding: 0.5rem 1rem;
    margin: 0.75rem 0;
    background: var(--bg-secondary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

/* Horizontal rules */
.markdown-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1rem 0;
}

.chat-input-container {
    display: flex;
    gap: 0.75rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.9375rem;
    transition: var(--transition);
}

.chat-input:focus,
#chatInput:focus,
.chat-input:focus-visible,
#chatInput:focus-visible {
    outline: none;
    border-color: var(--chat-focus-teal);
    box-shadow: 0 0 0 3px rgba(0, 184, 194, 0.34);
}

.chat-input::placeholder {
    font-style: italic;
    color: #7a8a94;
}

/* Searching Indicator */
.searching-indicator {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--secondary-color);
}

.searching-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Inline Citation Links */
.citation-link {
    display: inline;
    font-size: 0.75em;
    font-weight: 700;
    color: var(--primary-color);
    vertical-align: super;
    line-height: 1;
    padding: 0 0.1em;
}

.citation-link.clickable {
    cursor: pointer;
    border-bottom: 1px dotted var(--primary-color);
    transition: color 0.15s, border-color 0.15s;
}

.citation-link.clickable:hover {
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.citation-link.external {
    color: var(--text-muted);
}

/* Chat Sources */
.chat-sources {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-color);
}

.sources-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
}

.sources-header.collapsible {
    cursor: pointer;
    user-select: none;
}

.sources-header.collapsible:hover {
    color: var(--primary-color);
}

.sources-toggle {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.sources-list {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sources-header i:first-child {
    color: var(--primary-color);
}

.external-badge {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    background: var(--secondary-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.source-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: var(--transition);
}

.source-item.clickable {
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.source-item.clickable:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.source-number {
    font-weight: 700;
    color: var(--primary-color);
    min-width: 1.5rem;
    flex-shrink: 0;
}

.source-info {
    flex: 1;
}

.source-drug {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.source-drug i {
    color: var(--danger-color);
    font-size: 0.875rem;
}

.source-meta {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
}

/* Relevance badges */
.relevance-badge {
    display: inline-block;
    padding: 0.1em 0.5em;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: help;
    vertical-align: middle;
    white-space: nowrap;
}

.relevance-very-high {
    background: #d4edda;
    color: #155724;
}

.relevance-high {
    background: #d0e8ee;
    color: #1f5266;
}

.relevance-moderate {
    background: #fff3cd;
    color: #856404;
}

.relevance-weak {
    background: #e2e3e5;
    color: #383d41;
}

.relevance-low {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.relevance-raw {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: monospace;
}

.source-snippet {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.5rem;
    line-height: 1.4;
}

.source-link-icon {
    color: var(--primary-color);
    font-size: 0.875rem;
    opacity: 0;
    transition: var(--transition);
    flex-shrink: 0;
    align-self: center;
}

.source-item.clickable:hover .source-link-icon {
    opacity: 1;
}

/* Source Tags */
.source-tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 0.5rem;
}

.source-tag.pubmed {
    background: #10b981;
    color: white;
}

.source-tag.fda-label {
    background: #f59e0b;
    color: white;
}

.source-tag.fda-review {
    background: #ef4444;
    color: white;
}

.source-tag.fda {
    background: #3b82f6;
    color: white;
}

.source-tag.internal {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* ============================================
   ARCHIVE / EVIDENCE LIBRARY
   ============================================ */

.archive-section {
    overflow: visible;
}

.archive-section:hover {
    transform: none;
}

/* Accordion layout */
.archive-accordion {
    padding: 0.5rem 0;
}

.archive-drug-group {
    border-bottom: 1px solid var(--border-color);
}

.archive-drug-group:last-child {
    border-bottom: none;
}

.archive-drug-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
}

.archive-drug-header:hover {
    background: var(--bg-tertiary);
}

.drug-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.archive-chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    width: 1rem;
    text-align: center;
}

.archive-chevron.expanded {
    transform: rotate(90deg);
}

.drug-header-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.drug-header-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.2rem 0.625rem;
    border-radius: var(--radius-sm);
}

.archive-drug-body {
    padding: 0 1.5rem 1rem 2.75rem;
}

.archive-type-group {
    margin-bottom: 0.75rem;
}

.archive-type-group:last-child {
    margin-bottom: 0;
}

.archive-type-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    margin-bottom: 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.4);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
    user-select: none;
}

.archive-type-header:hover {
    background: var(--bg-tertiary);
}

.type-chevron {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.type-doc-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.archive-type-body {
    padding-left: 0.25rem;
    padding-top: 0.125rem;
}

.archive-doc-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.archive-doc-row:hover {
    background: var(--bg-tertiary);
}

.doc-icon {
    color: var(--danger-color);
    font-size: 0.875rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.doc-description {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.archive-doc-row .btn-view {
    flex-shrink: 0;
}

.archive-header {
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.archive-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.archive-title-row h2 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.archive-title-row h2 i {
    color: var(--primary-color);
}

.archive-doc-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
}

.archive-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.archive-filters {
    display: flex;
    gap: 0.375rem;
}

.archive-filter {
    padding: 0.375rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.archive-filter:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.archive-filter.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.archive-search {
    flex: 1;
    min-width: 200px;
    padding: 0.375rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.archive-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.archive-table-wrapper {
    overflow-x: auto;
}

.archive-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.archive-table thead {
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.archive-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    user-select: none;
}

.archive-table thead th.sortable {
    cursor: pointer;
    transition: color 0.15s ease;
}

.archive-table thead th.sortable:hover {
    color: var(--text-primary);
}

.archive-table thead th.sortable i {
    font-size: 0.625rem;
    margin-left: 0.375rem;
    opacity: 0.5;
}

.archive-table thead th.sort-asc i,
.archive-table thead th.sort-desc i {
    opacity: 1;
    color: var(--primary-color);
}

.archive-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.archive-table tbody tr:nth-child(even) {
    background: rgba(30, 41, 59, 0.3);
}

.archive-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.archive-table tbody td {
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.archive-table .drug-col {
    font-weight: 600;
    white-space: nowrap;
}

/* Archive badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge-bisphosphonate { background: #1e40af; color: #93c5fd; }
.badge-rankl_inhibitor { background: #581c87; color: #d8b4fe; }
.badge-anabolic { background: #065f46; color: #6ee7b7; }
.badge-sclerostin_inhibitor { background: #78350f; color: #fcd34d; }
.badge-unknown { background: var(--bg-tertiary); color: var(--text-secondary); }

.badge-review { background: #7f1d1d; color: #fca5a5; }
.badge-label { background: #78350f; color: #fcd34d; }
.badge-letter { background: #164e63; color: #67e8f9; }
.badge-rems { background: #581c87; color: #d8b4fe; }
.badge-other { background: var(--bg-tertiary); color: var(--text-secondary); }

.btn-view {
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--primary-color);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-view:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ============================================
   ABOUT PAGE
   ============================================ */

.about-section {
    padding: 2rem 2.5rem;
}

.about-section:hover {
    transform: none;
}

.about-content {
    max-width: 700px;
    margin: 0 auto;
}

.about-hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.about-icon {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    mix-blend-mode: lighten;
}

.about-hero h2 {
    font-size: 1.625rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.about-tagline {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.about-body {
    margin-bottom: 2.5rem;
}

.about-body p {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 0.875rem;
}

.about-body h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.about-body ul {
    list-style: none;
    padding: 0;
}

.about-body ul li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.about-body ul li::before {
    content: '\2022';
    color: var(--primary-color);
    font-weight: 700;
    position: absolute;
    left: 0;
}

/* Tech accordion */
.tech-accordion {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.tech-accordion .tech-accordion-summary {
    list-style: none;
    display: flex;
    width: fit-content;
    margin: 0 auto 1rem;
    cursor: pointer;
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.6rem 1.4rem;
    font-size: 0.9375rem;
    font-weight: 500;
    gap: 0.5rem;
    align-items: center;
    transition: var(--transition);
}

.tech-accordion .tech-accordion-summary::-webkit-details-marker {
    display: none;
}

.tech-accordion .tech-accordion-summary:hover {
    background: #3a5766;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.tech-accordion .tech-accordion-summary:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 3px;
}

.tech-accordion-chevron {
    transition: transform 0.25s ease;
}

details[open] .tech-accordion-chevron {
    transform: rotate(180deg);
}

.tech-accordion ul {
    margin-top: 1.25rem;
    width: 100%;
}

.about-creator {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.about-photo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.about-creator-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.about-creator-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.about-creator-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.about-creator-bio {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* ============================================
   PRIVACY & SECURITY PAGE
   ============================================ */

.privacy-content {
    max-width: 780px;
}

.privacy-title {
    font-size: 1.625rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.privacy-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.privacy-section:first-of-type {
    margin-top: 1.5rem;
}

.privacy-section h3 {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.125rem;
    margin-top: 0;
}

.privacy-section h3 i {
    color: var(--teal);
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.privacy-section ul {
    list-style: none;
    padding: 0;
}

.privacy-section ul li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.privacy-section ul li::before {
    content: '\f058';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: var(--teal);
    position: absolute;
    left: 0;
    top: 0.15em;
    font-size: 0.75rem;
}

.privacy-section ul li strong {
    color: var(--text-primary);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--teal);
    color: white;
}

.btn-primary:hover {
    background: #243a44;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: #c0392b;
    color: white;
}

.btn-danger:hover {
    background: #a93226;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-warning {
    background: #d68910;
    color: white;
}

.btn-warning:hover {
    background: #b7770d;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Footer */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.footer-left p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

.footer-link {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-top: 0.375rem;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--teal);
}

.footer-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.team-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.team-photo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-tertiary);
    filter: grayscale(100%);
}

.team-photo[src*="headshot.jpg"]:not([src]) {
    display: none;
}

.team-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.team-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.team-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.team-bio {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Placeholder Text */
.placeholder-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 2rem;
}

/* Scrollbar Styling — global (About, Evidence Library, etc.) */
::-webkit-scrollbar {
    width: 10px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #111827;
}

::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 5px;
    border: 2px solid #111827;  /* floating pill effect */
}

::-webkit-scrollbar-thumb:hover {
    background: #407786;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .team-badge {
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 1rem;
    }

    .header {
        padding: 0.75rem 0;
    }

    .main-nav {
        gap: 0;
    }

    .nav-link {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }

    .main-content {
        padding: 2rem 0;
    }

    .card-body {
        padding: 1rem;
    }

    .chat-input-container {
        flex-direction: row;
        gap: 0.5rem;
    }

    .chat-input-container .chat-input {
        width: 100%;
        text-align: left;
    }

    .chat-input-container .btn {
        width: auto;
    }

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

    .welcome-message h3 {
        font-size: 1.2rem;
    }

    .welcome-message p {
        max-width: 100%;
        font-size: 0.85rem;
    }

    .archive-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .archive-search {
        min-width: unset;
    }

    .about-section {
        padding: 2rem 1.5rem;
    }
}

/* PDF Modal */
.pdf-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.pdf-modal.active {
    display: flex;
}
.pdf-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
}
.pdf-modal-content {
    position: relative;
    width: 90%;
    max-width: 1100px;
    height: 85%;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.pdf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}
.pdf-modal-title {
    font-weight: 600;
}
.pdf-modal-actions {
    display: flex;
    gap: 0.5rem;
}
.pdf-modal-body {
    flex: 1;
    background: var(--bg-secondary);
}
.pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

@media (max-width: 640px) {
    .pdf-modal-content { height: 90%; width: 98%; }
}

/* ============================================
   AUTHENTICATION
   ============================================ */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    padding: 2rem;
}

.auth-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 3rem 2.5rem;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.auth-logo {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.auth-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.auth-form {
    text-align: left;
}

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

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-group input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: var(--transition);
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(71, 106, 122, 0.2);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.auth-btn {
    width: 100%;
    margin-top: 0.5rem;
    justify-content: center;
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}

.auth-switch {
    margin-top: 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--teal);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Nav auth elements */
.nav-user-name {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.5);
    padding: 0 0.5rem;
    align-self: center;
}

.nav-logout {
    opacity: 0.6;
}

.nav-logout:hover {
    opacity: 1;
}

.admin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--teal);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ============================================
   ADMIN PANEL
   ============================================ */

.admin-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-card-header i {
    color: var(--teal);
    font-size: 1.25rem;
}

.admin-card-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

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

.admin-group h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.admin-user-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    gap: 1rem;
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    min-width: 0;
}

.admin-user-detail {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-style: italic;
}

.admin-user-email {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

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

.admin-user-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Inline approval / role-change form inside admin user rows */
.admin-approve-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-field-label {
    display: flex;
    flex-direction: column;
    font-size: 0.7rem;
    color: var(--text-muted);
    gap: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.admin-select {
    font-size: 0.8125rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-width: 8rem;
    cursor: pointer;
}

.badge-approved {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.badge-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-reset-requested {
    background: rgba(214, 137, 16, 0.15);
    color: #d68910;
    font-size: 0.75rem;
}

/* Auth success message (e.g. forgot password confirmation) */
.auth-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid #22c55e;
    color: #166534;
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

/* Temp password reveal block */
.temp-pw-display {
    font-family: monospace;
    font-size: 1.25rem;
    letter-spacing: 0.1em;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    text-align: center;
    margin-top: 0.75rem;
    user-select: all;
}

@media (max-width: 640px) {
    .auth-card {
        padding: 2rem 1.5rem;
    }
    .admin-user-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* ============================================
   PASSWORD CHANGE MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.auth-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid #22c55e;
    color: #22c55e;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}

#nav-user-name {
    cursor: pointer;
    text-decoration: none;
    color: var(--text-secondary);
}
#nav-user-name:hover {
    color: var(--text-primary);
}

/* Chat policy notices block (below chat card, above footer) */
#chatPolicyNotices {
    margin-top: 0.875rem;
    padding: 0 0.25rem;
}

.chat-data-notice {
    font-size: 0.75rem;
    color: var(--teal);
    line-height: 1.5;
    margin-bottom: 0;
}

/* Bookmark button bar below a chat answer */
.chat-bookmark-bar {
    display: flex;
    justify-content: flex-end;
    margin: 0.25rem 0 0.75rem;
}

.bookmark-btn {
    font-size: 0.8125rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.bookmark-btn:hover { opacity: 1; }

/* Footer disclosure */
.footer-disclosure {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    max-width: 360px;
    line-height: 1.5;
}

/* ============================================
   ADMIN TABS  (reused by Admin + Dashboard)
   ============================================ */

.admin-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1.5rem 0;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.admin-tab {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.admin-tab:hover { color: var(--text-primary); }

.admin-tab.active {
    color: var(--teal);
    border-bottom-color: var(--teal);
}

.admin-tab-panel {
    min-height: 200px;
}

/* Small admin table used in Orgs tab */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.admin-table thead th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
}
.admin-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid rgba(51,65,85,0.4);
    color: var(--text-primary);
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--bg-tertiary); }

/* Audit log list */
.audit-log-list { display: flex; flex-direction: column; gap: 0.375rem; }
.audit-log-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}
.audit-log-time { color: var(--text-muted); font-size: 0.75rem; min-width: 10rem; }
.audit-log-user { color: var(--text-secondary); }
.audit-log-action { font-weight: 600; color: var(--teal); }
.audit-log-resource { color: var(--text-muted); font-size: 0.75rem; flex: 1; }
.audit-log-org {
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

/* ============================================
   WORKSPACE / DASHBOARD
   ============================================ */

.dashboard-section { overflow: visible; }
.dashboard-section:hover { transform: none; }

/* History rows */
.history-row {
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border-color);
}
.history-row:last-child { border-bottom: none; }
.history-question {
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.history-meta {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.history-engine {
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}
.history-actions { display: flex; gap: 0.5rem; }

/* Saved answer cards */
.saved-answer-card {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    transition: border-color 0.15s;
}
.saved-answer-card:hover { border-color: var(--teal); }
.saved-answer-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.saved-answer-question {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.saved-answer-actions { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }

/* Tags */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.5rem; }
.tag-chip {
    padding: 0.2rem 0.6rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Collection cards */
.collection-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}
.collection-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
}
.collection-meta { font-size: 0.8125rem; color: var(--text-muted); }
.collection-actions { flex-shrink: 0; }

/* ============================================
   PROFILE PANEL (slide-in from right)
   ============================================ */

.profile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 900;
    backdrop-filter: blur(2px);
}

.profile-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
}

.profile-panel.open {
    transform: translateX(0);
}

.profile-panel-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--teal);
    color: white;
    font-size: 1.125rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-panel-identity { flex: 1; min-width: 0; }
.profile-panel-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-panel-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-panel-meta {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.profile-meta-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.profile-meta-row i { color: var(--text-muted); width: 0.875rem; text-align: center; }

.profile-role-badge {
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.profile-role-system-admin { background: rgba(71,106,122,0.25); color: var(--teal); }
.profile-role-org-admin    { background: rgba(59,130,246,0.15); color: #60a5fa; }
.profile-role-user         { background: var(--bg-tertiary); color: var(--text-secondary); }
.profile-role-admin        { background: rgba(71,106,122,0.25); color: var(--teal); }

.profile-panel-actions {
    padding: 0.875rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
}

.profile-action-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    text-align: left;
}
.profile-action-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.profile-action-btn i { width: 1rem; text-align: center; color: var(--text-muted); }
.profile-action-danger:hover { color: var(--danger-color); }
.profile-action-danger:hover i { color: var(--danger-color); }

/* ============================================
   USAGE ANALYTICS
   ============================================ */

.usage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.usage-range-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}
.usage-range-btns {
    display: flex;
    gap: 0.375rem;
}

.usage-kpi-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.usage-kpi-card {
    flex: 1;
    min-width: 120px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    text-align: center;
}
.usage-kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--teal);
    line-height: 1.2;
}
.usage-kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.usage-section {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}
.usage-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* Daily trend bar chart */
.usage-trend {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.usage-trend-row {
    display: grid;
    grid-template-columns: 3.5rem 1fr 2rem;
    align-items: center;
    gap: 0.5rem;
}
.usage-trend-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.usage-trend-bar-wrap {
    background: var(--bg-tertiary);
    border-radius: 2px;
    height: 8px;
    overflow: hidden;
}
.usage-trend-bar {
    height: 100%;
    background: var(--teal);
    border-radius: 2px;
    min-width: 2px;
    transition: width 0.3s ease;
}
.usage-trend-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
}

/* Usage tables */
.usage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.usage-table thead th {
    text-align: left;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
}
.usage-table tbody td {
    padding: 0.35rem 0.5rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(51,65,85,0.4);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}
.usage-table tbody tr:last-child td { border-bottom: none; }
.usage-count {
    font-weight: 600;
    color: var(--teal);
    text-align: right;
}

/* ============================================
   FULL-VIEWPORT CHAT LAYOUT
   Scoped under body.chat-active so other pages
   are completely unaffected.
   Uses CSS Grid (2 constraint points) instead
   of a deep flex-chain.
   ============================================ */

/* ── viewport lock ──────────────────────────── */
html.chat-active,
body.chat-active {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

/* ── body grid: header row + main row ───────── */
body.chat-active {
    display: grid;
    grid-template-rows: auto 1fr;
}

/* ── flatten wrappers between body and card-body ── */
body.chat-active .main-content {
    padding: 0;
    min-height: 0;
    overflow: hidden;
}

body.chat-active .main-content > .container {
    max-width: none;
    padding: 0;
    height: 100%;
}

body.chat-active #page-chat,
body.chat-active .main-query-section,
body.chat-active .main-query-section > .card-body {
    height: 100%;
}

/* ── neutralise .card base styles ──────────── */
body.chat-active .main-query-section {
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    margin-bottom: 0;
    overflow: visible;
    transform: none;
}
body.chat-active .main-query-section:hover {
    transform: none;
    box-shadow: none;
}

/* ── card-body grid: messages 1fr + input auto ── */
body.chat-active .main-query-section > .card-body {
    padding: 0;
    display: grid;
    grid-template-rows: 1fr auto;
}

/* ── chat messages: scrollable area ────────── */
body.chat-active .chat-messages {
    min-height: 0;
    max-height: none;
    overflow-y: auto !important;
    overflow-x: hidden;
    border-radius: 0;
    padding: 1rem 1.5rem 1.5rem;
}

/* Centre all direct children within a 1200px column */
body.chat-active .chat-messages > * {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

/* ── welcome hero: compact fallback if still in DOM ── */
body.chat-active .welcome-message {
    padding: 1rem 2rem;
}
body.chat-active .welcome-logo {
    height: 35px;
    width: 35px;
}
body.chat-active .welcome-message p {
    display: none;
}

/* ── scrollbar: Track #0f172a · Thumb #475569 · Hover #2dd4bf ── */
body.chat-active .chat-messages::-webkit-scrollbar {
    width: 10px;
}
body.chat-active .chat-messages::-webkit-scrollbar-track {
    background: #0f172a;
}
body.chat-active .chat-messages::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 5px;
    border: 2px solid #0f172a;
}
body.chat-active .chat-messages::-webkit-scrollbar-thumb:hover {
    background: #2dd4bf;
}

/* ── chat input: pinned to bottom ──────────── */
body.chat-active .chat-input-container {
    padding: 0.75rem 1.5rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

body.chat-active #chatPolicyNotices {
    display: none;
}

body.chat-active .footer {
    display: none;
}

@media (max-width: 640px) {
    body.chat-active .main-query-section > .card-body {
        padding: 0 0.75rem;
    }
}

/* Keep chat input focus styling consistent in all chat layouts/states */
body #chatInput:focus,
body #chatInput:focus-visible {
    outline: none;
    border-color: var(--chat-focus-teal) !important;
    box-shadow: 0 0 0 3px rgba(0, 184, 194, 0.34) !important;
}
