/* Modern, Premium CSS with Glassmorphism and animations */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-primary: #2563eb;
    --accent-primary-hover: #1d4ed8;
    --accent-glow: rgba(37, 99, 235, 0.2);
    --border-color: rgba(15, 23, 42, 0.1);
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-pill: 9999px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    background: radial-gradient(circle at top right, #ffffff 0%, #f1f5f9 100%);
}

.sidebar {
    width: 280px;
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Sidebar Components */
.sidebar-header {
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 32px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.nav-btn svg {
    width: 20px;
    height: 20px;
}

.nav-btn:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
}

.nav-btn.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    border-left: 3px solid var(--accent-primary);
}

.sidebar-filters {
    flex: 1;
    overflow-y: auto;
}

.sidebar-filters h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.filter-group label {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: block;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.filter-item input[type="checkbox"] {
    accent-color: var(--accent-primary);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
}

/* Views */
.views-wrapper {
    flex: 1;
    position: relative;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.view.active {
    opacity: 1;
    pointer-events: all;
}

/* Chat Header */
.chat-header {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 5;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mode-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.welcome-screen {
    margin: auto;
    text-align: center;
    max-width: 600px;
    padding: 40px 20px;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-screen h2 {
    font-size: 28px;
    margin-bottom: 12px;
    font-weight: 600;
}

.welcome-screen p {
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.suggestion-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-ld);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease-up;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.message.user .message-bubble {
    background: var(--accent-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

/* Markdown Specifics */
.message-bubble ul,
.message-bubble ol {
    margin-top: 12px;
    margin-bottom: 12px;
    padding-left: 24px;
}

.message-bubble li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.message-bubble li>ul,
.message-bubble li>ol {
    margin-top: 4px;
    margin-bottom: 4px;
    padding-left: 24px;
}

/* Citations styling */
.citations-block {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.citation {
    background: rgba(37, 99, 235, 0.05);
    border-left: 3px solid #6366f1;
    padding: 10px 12px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 13px;
}

.citation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.citation-title {
    font-weight: 600;
    color: #a78bfa;
}

.citation-link {
    color: var(--accent-primary);
    text-decoration: none;
}

.citation-link:hover {
    text-decoration: underline;
}

.citation-excerpt {
    color: var(--text-secondary);
    font-style: italic;
}

.uncertainty-alert {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--warning);
    padding: 12px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-top: 12px;
    font-size: 13px;
    color: #fcd34d;
}

/* Tooling / Input styling */
.chat-input-container {
    padding: 0 24px 24px 24px;
    background: transparent;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.chat-input-container textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 12px;
    font-family: inherit;
    font-size: 15px;
    resize: none;
    outline: none;
    max-height: 150px;
    min-height: 44px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

.input-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 12px;
}

/* Files preview */
.files-preview {
    padding: 0 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.file-badge {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Buttons */
.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
}

.w-100 {
    width: 100%;
}

.mt-3 {
    margin-top: 12px;
}

/* Catalog Specific */
.catalog-header {
    padding: 32px;
    border-bottom: 1px solid var(--border-color);
}

.catalog-grid {
    padding: 32px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    overflow-y: auto;
}

.catalog-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.2s;
}

.catalog-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

/* Utils */
.hidden {
    display: none !important;
}

/* Loader */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    width: fit-content;
    animation: fadeIn 0.3s ease;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: #ffffff;
    padding: 32px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    width: 400px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-top: 16px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 50%;
    /* Animated in JS */
    background: var(--accent-primary);
    border-radius: 4px;
    animation: progressIndeterminate 1.5s infinite linear;
}

@keyframes progressIndeterminate {
    0% {
        transform: translateX(-100%);
        width: 50%;
    }

    100% {
        transform: translateX(200%);
        width: 50%;
    }
}

.text-xs {
    font-size: 12px;
}

.text-muted {
    color: var(--text-secondary);
}

/* DORA View Specifics */
.dora-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    animation: fadeIn 0.5s ease;
}

.dora-loader-container .loader-spinner {
    width: 60px;
    height: 60px;
    border-width: 4px;
    border-color: var(--bg-secondary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.dora-report-container {
    padding: 24px 40px 60px 40px;
    max-width: 900px;
    margin: 0 auto;
    overflow-y: auto;
    height: calc(100vh - 120px);
    animation: fadeIn 0.6s ease;
}

.report-block {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.report-block h3 {
    font-size: 18px;
    color: var(--accent-primary);
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-top: 16px;
}

.data-table th,
.data-table td {
    border: 1px solid var(--border-color);
    padding: 16px;
    text-align: left;
    vertical-align: top;
    line-height: 1.5;
}

.data-table th {
    background: #f1f5f9;
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 13px;
    /* Removed white-space: nowrap; to allow text wrapping and stop overflow */
}

.data-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.data-table tbody tr:hover {
    background: #f0fdf4;
    /* Very light green on hover */
}

.table-responsive {
    width: 100%;
    margin-top: 16px;
    /* Removed overflow-x to satisfy user request - table will expand or wrap */
}

.mermaid-container {
    display: flex;
    justify-content: center;
    background: #f8fafc;
    padding: 32px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    width: 100%;
}

.mermaid svg {
    max-width: 100%;
    height: auto !important;
}