:root {
    --bg-base: #f8fafc;         /* Slate 50: Clean slate background */
    --bg-panel: #ffffff;        /* Pure white for panels and cards */
    --bg-input: #f1f5f9;        /* Slate 100 for inputs */
    --border-soft: #f1f5f9;      /* Subtle border line */
    --border-hard: #e2e8f0;      /* Slate 200 for card borders */
    --border-focus: #0f766e;     /* Teal 700 on focus */
    
    --text-main: #0f172a;       /* Slate 900: Dark charcoal for text */
    --text-dim: #475569;        /* Slate 600: Soft gray for labels and titles */
    --text-muted: #94a3b8;      /* Slate 400: Metadata */
    
    --accent-raw: #0f766e;      /* Deep Teal */
    --accent-dim: rgba(15, 118, 110, 0.05); /* Light teal backdrop */
    --accent-light: #f0fdfa;    /* Soft mint highlight */
    --accent-hover: #115e59;    /* Teal 800 */
    
    --alert-error: #e11d48;     /* Rose 600 */
    --alert-success: #16a34a;   /* Emerald 600 */
    
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Lora', Georgia, serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition-smooth: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.03), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    --shadow-card: 0 10px 15px -3px rgba(15, 23, 42, 0.04), 0 4px 6px -2px rgba(15, 23, 42, 0.02);
}

/* Minimalist Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-hard);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-display);
    background: var(--bg-base);
    color: var(--text-main);
    height: 100vh;
    width: 100vw;
    display: flex;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-hard);
    display: flex;
    flex-direction: column;
    padding: 24px;
    flex-shrink: 0;
    position: relative;
    box-shadow: 2px 0 12px rgba(15, 23, 42, 0.02);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-soft);
}

.logo-icon {
    width: 12px;
    height: 12px;
    background: var(--accent-raw);
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
}

.logo-text {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

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

.new-session-btn {
    width: 100%;
    background: var(--accent-raw);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.new-session-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.2);
}

.history-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.session-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.session-item {
    border: 1px solid var(--border-hard);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    background: var(--bg-panel);
    position: relative;
}

.session-item:hover {
    border-color: var(--accent-raw);
    background: var(--bg-base);
}

.session-item.active {
    border-color: var(--accent-raw);
    background: var(--accent-dim);
}

.session-item .date {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.session-item .title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-mono);
}

.session-item .status-dot {
    position: absolute;
    top: 15px;
    right: 12px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-raw);
}

.version-footer {
    margin-top: auto;
    padding-top: 16px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- MAIN CONTENT & CHAT --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-hard);
    position: relative;
    background: var(--bg-base);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border-hard);
    background: var(--bg-panel);
    z-index: 10;
}

.header-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.retrieval-select {
    background: var(--bg-base);
    border: 1px solid var(--border-hard);
    border-radius: 6px;
    color: var(--text-main);
    padding: 6px 12px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.retrieval-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.1);
}

.hero-section {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: left;
    width: 85%;
    max-width: 640px;
    z-index: 20;
    padding: 32px;
    background: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid var(--border-hard);
    box-shadow: var(--shadow-card);
    transition: opacity 0.3s ease;
}

.hero-tag {
    display: inline-block;
    color: var(--accent-raw);
    background: var(--accent-dim);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hero-title {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 12px;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.hero-subtitle {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.5;
}

.sample-queries {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sample-queries-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.sample-query-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-hard);
    border-radius: 8px;
    padding: 12px 16px;
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition-smooth);
    line-height: 1.4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.sample-query-card:hover {
    border-color: var(--accent-raw);
    background: var(--bg-base);
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.sample-query-card::after {
    content: "Run →";
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-raw);
    opacity: 0;
    transform: translateX(-4px);
    transition: var(--transition-smooth);
}

.sample-query-card:hover::after {
    opacity: 1;
    transform: translateX(0);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 32px 10%;
    display: flex;
    flex-direction: column;
    gap: 24px;
    z-index: 10;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
    font-family: var(--font-display);
    border: 1px solid var(--border-hard);
}

.ai .avatar {
    background: var(--accent-light);
    color: var(--accent-raw);
    border-color: var(--accent-raw);
}

.user .avatar {
    background: var(--text-main);
    color: #ffffff;
    border-color: var(--text-main);
}

.message-content {
    padding: 16px 20px;
    font-size: 14.5px;
    line-height: 1.6;
    background: var(--bg-panel);
    border: 1px solid var(--border-hard);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    color: var(--text-main);
}

.user .message-content {
    background: var(--accent-raw);
    color: #ffffff;
    border-color: var(--accent-raw);
    border-top-right-radius: 2px;
}

.ai .message-content {
    font-family: var(--font-body);
    border-top-left-radius: 2px;
}

.ai .message-content p {
    margin-bottom: 12px;
}

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

.ai .message-content a {
    color: var(--accent-raw);
    text-decoration: none;
    font-weight: 600;
}

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

/* Citations & Sources Box */
.source-link {
    color: var(--accent-raw);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 11px;
    vertical-align: super;
    cursor: pointer;
    margin: 0 2px;
    display: inline-block;
    transition: var(--transition-smooth);
}

.user .source-link {
    color: #ffffff;
}

.source-link:hover {
    color: var(--accent-hover);
    transform: scale(1.1);
}

.sources-box {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-base);
    border-radius: 8px;
    border: 1px solid var(--border-hard);
}

.sources-title {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-item {
    margin-bottom: 6px;
    font-size: 12px;
    font-family: var(--font-mono);
    line-height: 1.4;
    color: var(--text-dim);
}

.source-item:last-child {
    margin-bottom: 0;
}

.source-item .source-link {
    vertical-align: baseline;
    font-size: 12px;
    margin-right: 4px;
}

/* Confidence Meters */
.confidence-box {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-base);
    border-radius: 8px;
    border: 1px dashed var(--border-hard);
    font-family: var(--font-display);
}

.confidence-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.confidence-title {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-dim);
}

.confidence-score {
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-raw);
}

.confidence-bar-container {
    height: 6px;
    background: var(--border-hard);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.confidence-bar {
    height: 100%;
    background: var(--accent-raw);
    border-radius: 3px;
    transition: width 1s ease-in-out;
}

.confidence-details {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* Chat Input Bar */
.input-container {
    padding: 0 10% 24px 10%;
    z-index: 10;
}

.chat-form {
    background: var(--bg-panel);
    border: 1px solid var(--border-hard);
    border-radius: 12px;
    padding: 16px;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
    transition: var(--transition-smooth);
}

.chat-form:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 10px 15px -3px rgba(15, 118, 110, 0.04), 0 0 0 3px rgba(15, 118, 110, 0.08);
}

.chat-form-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.user-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-display);
    font-size: 14.5px;
    outline: none;
    padding-bottom: 44px;
    resize: none;
    line-height: 1.5;
}

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

.send-button {
    position: absolute;
    right: 16px;
    bottom: 16px;
    background: var(--accent-raw);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.send-button:hover {
    background: var(--accent-hover);
}

.send-button:disabled {
    background: var(--border-hard);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* --- MANAGE PANE --- */
.manage-wrapper {
    width: 320px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-hard);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
    flex-shrink: 0;
    box-shadow: -2px 0 12px rgba(15, 23, 42, 0.02);
}

.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-hard);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-soft);
}

.section-title {
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 8px;
    text-transform: uppercase;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 12px;
}

.stats-table th {
    text-align: left;
    padding-bottom: 8px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-hard);
    font-weight: 600;
}

.stats-table td {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-soft);
    font-family: var(--font-mono);
    color: var(--text-dim);
}

.stats-table td:first-child {
    color: var(--text-main);
    font-weight: 500;
}

.form-group {
    margin-bottom: 16px;
}

.file-input-field {
    width: 100%;
    background: var(--bg-base);
    border: 1px dashed var(--border-hard);
    border-radius: 8px;
    padding: 16px;
    color: var(--text-dim);
    outline: none;
    font-family: var(--font-display);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-align: center;
}

.file-input-field:hover {
    border-color: var(--accent-raw);
    background: var(--accent-dim);
}

.primary-btn {
    width: 100%;
    background: var(--bg-panel);
    color: var(--text-main);
    border: 1px solid var(--border-hard);
    border-radius: 8px;
    padding: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.primary-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent-raw);
    color: var(--accent-raw);
}

.primary-btn:disabled {
    border-color: var(--border-soft);
    color: var(--text-muted);
    background: var(--bg-base);
    cursor: not-allowed;
}

.status-msg {
    margin-top: 12px;
    padding: 10px 12px;
    font-size: 12px;
    border-radius: 6px;
    border-left: 3px solid;
}

.status-msg.success {
    background: #f0fdf4;
    color: var(--alert-success);
    border-left-color: var(--alert-success);
}

.status-msg.error {
    background: #fff1f2;
    color: var(--alert-error);
    border-left-color: var(--alert-error);
}

.hidden {
    display: none !important;
}

/* --- TYPING INDICATOR --- */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--accent-raw);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

.demo-banner {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-hard);
    background: var(--bg-base);
}

.demo-banner-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-raw);
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.demo-banner-text {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.4;
}

.demo-disabled {
    opacity: 0.4;
    pointer-events: none;
    position: relative;
}

.demo-disabled::after {
    content: "DISABLED IN DEMO";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 1px;
    border-radius: 8px;
}

/* --- PORTFOLIO CONTACT BOX --- */
.portfolio-box {
    margin-top: auto;
    display: block;
    background: var(--bg-base);
    border: 1px solid var(--border-hard);
    border-radius: 8px;
    padding: 16px;
    text-decoration: none;
    transition: var(--transition-smooth);
    position: relative;
}

.portfolio-box:hover {
    border-color: var(--accent-raw);
    background: var(--accent-dim);
    box-shadow: var(--shadow-soft);
}

.portfolio-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-raw);
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.portfolio-text {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.4;
    margin-bottom: 8px;
}

.portfolio-link {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    justify-content: flex-end;
}

.portfolio-box:hover .portfolio-link {
    color: var(--accent-raw);
}

.fade-in-up {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

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