/* Modern Layout - Inspired by SCMS AI.AI Screenshots */

/* Import DM Sans from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap');

/* ============================
   Typography System
   ============================ */
:root {
    /* Font Families */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;

    /* Font Size Scale (Base: 13px / 0.8125rem) */
    --text-2xs: 0.5625rem;    /* 9px - micro labels */
    --text-xs: 0.625rem;      /* 10px - tiny labels, table headers */
    --text-sm: 0.6875rem;     /* 11px - small text, badges */
    --text-base: 0.8125rem;   /* 13px - default body text */
    --text-md:  0.8125rem;      /* 14px - nav links, larger body */
    --text-lg: 1rem;          /* 16px - section headers */
    --text-xl: 1.125rem;      /* 18px - panel titles */
    --text-2xl: 1.25rem;      /* 20px - page headers */
    --text-3xl: 1.5rem;       /* 24px - large headings */

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Line Heights */
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
}

/* ============================
   Color Palette (Light Mode)
   ============================ */
:root {
    /* Primary Colors */
    --primary-blue: #1976d2;
    --primary-blue-hover: #1565c0;
    --primary-blue-light: #e3f2fd;

    /* Background Colors */
    --bg-main: #f5f7fa;
    --bg-white: #ffffff;
    --bg-gray-50: #fafafa;
    --bg-gray-100: #f5f5f5;
    --bg-gray-200: #eeeeee;

    /* Text Colors */
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --text-white: #ffffff;

    /* Border Colors */
    --border-light: #e0e0e0;
    --border-medium: #d0d0d0;
    --border-dark: #bdbdbd;

    /* Success/Error Colors */
    --success-green: #4caf50;
    --success-green-light: #e8f5e9;
    --error-red: #f44336;
    --warning-orange: #ff9800;

    /* Shadow */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);

    /* Spacing */
    --header-height: 64px;
    --content-max-width: 1400px;

    /* Surface tokens */
    --surface-card: #ffffff;
    --surface-card-muted: #f4f6fb;
    --surface-card-strong: #e3f2fd;
    --surface-border: #e0e6f0;
}

/* ============================
   Color Palette (Dark Mode)
   ============================ */
[data-theme="dark"] {
    /* Primary Colors */
    --primary-blue: #42a5f5;
    --primary-blue-hover: #64b5f6;
    --primary-blue-light: #1e3a5f;

    /* Background Colors */
    --bg-main: #0f1419;
    --bg-white: #1a1f2e;
    --bg-gray-50: #232935;
    --bg-gray-100: #2d3748;
    --bg-gray-200: #374151;

    /* Text Colors */
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --text-white: #ffffff;

    /* Border Colors */
    --border-light: #374151;
    --border-medium: #4b5563;
    --border-dark: #6b7280;

    /* Success/Error Colors */
    --success-green: #66bb6a;
    --success-green-light: #1b3d1c;
    --error-red: #ef5350;
    --warning-orange: #ffa726;

    /* Shadow */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);

    /* Surface tokens */
    --surface-card: #1a1f2e;
    --surface-card-muted: #232b40;
    --surface-card-strong: #243351;
    --surface-border: #2d3548;
}

/* ============================
   Theme Transition
   ============================ */
body,
.modern-layout,
.top-header,
.user-dropdown-menu,
.dropdown-item,
.icon-button,
.user-menu,
.nav-link,
.btn-login,
.btn-register {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ============================
   Layout Structure
   ============================ */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: var(--leading-normal);
}

.modern-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================
   Top Header
   ============================ */
.top-header {
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

.header-content {
    height: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Header Left - Brand + Navigation */
.header-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

/* Brand Section */
.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-box {
    width: 32px;
    height: 32px;
    background: linear-gradient(to bottom right, #1e293b, #0f172a);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.logo-box span {
    color: white;
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    letter-spacing: -0.5px;
}

[data-theme="dark"] .logo-box {
    background: linear-gradient(to bottom right, #3b82f6, #1d4ed8);
}

.brand-text {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.brand-name {
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.brand-subtitle {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    font-weight: var(--font-normal);
}

/* ============================
   Main Navigation
   ============================ */
.main-navigation {
    display: flex;
    align-items: center;
    gap: 4px;
}

.main-navigation .nav-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: var(--font-medium);
    font-size: var(--text-base);
    transition: all 0.15s ease;
}

.main-navigation .nav-link:hover {
    background-color: var(--bg-gray-100);
    color: var(--text-primary);
}

.main-navigation .nav-link.active {
    color: var(--text-primary);
    background-color: var(--bg-gray-100);
}

/* ============================
   Header Actions & User Menu
   ============================ */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-icon-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    position: relative;
}

.header-icon-btn:hover {
    background-color: var(--bg-gray-100);
    color: var(--text-secondary);
}

.header-icon {
    width: 20px;
    height: 20px;
}

.header-icon-btn--notifications .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
}

/* Notification Bell Component */
.notification-container {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
    background-color: #ef4444;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-white);
}

[data-theme="dark"] .notification-badge {
    border-color: var(--bg-main);
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

[data-theme="dark"] .notification-dropdown {
    background: var(--bg-card);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.notification-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.notification-actions {
    display: flex;
    gap: 4px;
}

.notification-action-btn {
    background: none;
    border: none;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.notification-action-btn:hover {
    background: var(--bg-gray-100);
    color: var(--text-primary);
}

.notification-action-btn .material-icons {
    font-size: 18px;
}

.notification-list {
    flex: 1;
    overflow-y: auto;
    max-height: 360px;
}

.notification-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-tertiary);
}

.notification-empty .material-icons {
    font-size: 48px;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.notification-empty p {
    margin: 0;
    font-size: 0.875rem;
}

.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s ease;
}

.notification-item:hover {
    background: var(--bg-gray-50);
}

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

.notification-item--unread {
    background: rgba(59, 130, 246, 0.05);
}

.notification-item--unread:hover {
    background: rgba(59, 130, 246, 0.1);
}

.notification-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-gray-100);
    border-radius: 8px;
    color: var(--primary-color);
}

.notification-icon .material-icons {
    font-size: 18px;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-message {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-time {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
    display: block;
}

.notification-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-light);
}

.notification-view-all {
    width: 100%;
    padding: 0.5rem;
    background: none;
    border: none;
    font-size: 0.8125rem;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 500;
    transition: color 0.15s ease;
}

.notification-view-all:hover {
    color: var(--primary-hover);
}

/* Help button with page help available indicator */
.header-icon-btn--help-available {
    position: relative;
}

.header-icon-btn--help-available .help-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    background-color: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--bg-white);
    animation: pulse-help 2s ease-in-out infinite;
}

@keyframes pulse-help {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

[data-theme="dark"] .header-icon-btn--help-available .help-indicator {
    border-color: var(--bg-main);
}

.header-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-light);
    margin: 0 4px;
}

/* Legacy icon-button support */
.icon-button {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.icon-button:hover {
    background-color: var(--bg-gray-100);
    color: var(--text-secondary);
}

.material-icons {
    font-size: 20px;
}

/* User Menu Container - positioned ancestor for dropdown */
.user-menu-container {
    position: relative;
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 4px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.user-menu:hover {
    background-color: var(--bg-gray-100);
}

/* New gradient avatar */
.user-avatar-new {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(to bottom right, #3b82f6, #2563eb);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Legacy avatar support */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(to bottom right, #3b82f6, #2563eb);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar .material-icons {
    font-size: 20px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-name {
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    line-height: var(--leading-tight);
}

.user-role {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    line-height: var(--leading-tight);
}

.dropdown-chevron {
    color: var(--text-tertiary);
    transition: transform 0.15s ease;
}

.dropdown-chevron--open {
    transform: rotate(180deg);
}

/* Legacy dropdown arrow */
.dropdown-arrow {
    font-size: 18px !important;
    color: var(--text-tertiary);
}

/* User Dropdown Menu */
.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background-color: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    padding: 8px;
    z-index: 1001;
    animation: dropdownFadeIn 0.2s ease;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: var(--text-base);
    transition: all 0.2s ease;
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: var(--bg-gray-100);
}

.dropdown-item .material-icons {
    font-size: 20px;
    color: var(--text-secondary);
}

.dropdown-item-form {
    margin: 0;
    padding: 0;
}

.logout-item {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    font-family: inherit;
    color: var(--error-red);
}

.logout-item:hover {
    background-color: #ffebee;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-light);
    margin: 8px 0;
}

/* Login/Register Buttons */
.btn-login, .btn-register {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: var(--font-medium);
    font-size: var(--text-base);
    transition: all 0.2s ease;
    display: inline-block;
}

.btn-login {
    color: var(--primary-blue);
    background-color: transparent;
    border: 1px solid var(--primary-blue);
}

.btn-login:hover {
    background-color: var(--primary-blue-light);
}

.btn-register {
    color: white;
    background-color: var(--primary-blue);
    border: 1px solid var(--primary-blue);
}

.btn-register:hover {
    background-color: var(--primary-blue-hover);
}

/* ============================
   Main Content Area
   ============================ */
.main-content-area {
    flex: 1;
    width: 100%;
    background-color: var(--bg-main);
    overflow-y: auto;
    padding-top: var(--header-height);
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    padding-bottom: 2rem;
}

/* ============================
   App Footer
   ============================ */
.app-footer {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border-light);
    background-color: var(--bg-white);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.app-footer a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.app-footer a:hover {
    color: var(--primary-blue);
}

/* Boxed layout mode - constrain content width */
.modern-layout.layout-boxed .main-content-area {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding-left: 2rem;
    padding-right: 2rem;
}

.modern-layout.layout-boxed .header-content {
    max-width: var(--content-max-width);
}

/* Full width layout mode */
.modern-layout.layout-full-width .header-content {
    max-width: none;
}

.account-layout .main-content-area {
    padding-top: 2rem;
}

/* ============================
   Mobile Menu Toggle Button
   ============================ */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.mobile-menu-toggle:hover {
    background-color: var(--bg-gray-100);
    color: var(--text-primary);
}

.mobile-menu-toggle .material-icons {
    font-size: 24px;
}

/* ============================
   Mobile Navigation Overlay
   ============================ */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ============================
   Mobile Navigation Drawer
   ============================ */
.mobile-nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-white);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.mobile-nav-drawer.open {
    transform: translateX(0);
}

.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.mobile-nav-header .brand-section {
    gap: 8px;
}

.mobile-nav-header .brand-text {
    display: flex;
}

.mobile-nav-close {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.mobile-nav-close:hover {
    background-color: var(--bg-gray-100);
    color: var(--text-primary);
}

.mobile-nav-links {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: var(--font-medium);
    font-size: var(--text-md);
    transition: all 0.15s ease;
}

.mobile-nav-link:hover {
    background-color: var(--bg-gray-100);
    color: var(--text-primary);
}

.mobile-nav-link.active {
    background-color: var(--primary-blue-light);
    color: var(--primary-blue);
}

.mobile-nav-link .material-icons {
    font-size: 20px;
    opacity: 0.8;
}

/* Dark mode for mobile nav */
[data-theme="dark"] .mobile-nav-drawer {
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .mobile-nav-link.active {
    background-color: rgba(66, 165, 245, 0.15);
    color: var(--primary-blue);
}

/* ============================
   Responsive Design
   ============================ */
/* Tablet breakpoint - hide some header items */
@media (max-width: 992px) {
    .brand-subtitle {
        display: none;
    }

    .header-actions {
        gap: 4px;
    }
}

/* Mobile breakpoint - show hamburger, hide desktop nav */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .desktop-nav {
        display: none;
    }

    .brand-text {
        display: none;
    }

    .user-info {
        display: none;
    }

    .dropdown-arrow {
        display: none;
    }

    .header-divider {
        display: none;
    }

    .header-actions {
        gap: 2px;
    }

    /* Hide some less important header buttons on mobile */
    .header-actions > :not(.user-menu-container):not(.icon-button):not(button) {
        display: none;
    }
}

/* Small mobile - further reduce spacing */
@media (max-width: 480px) {
    .header-content {
        padding: 0 12px;
    }

    .icon-button {
        padding: 6px;
    }

    .material-icons {
        font-size: 20px;
    }

    .mobile-nav-drawer {
        width: 100%;
        max-width: 100%;
    }
}

/* ============================
   Material Icons Font
   ============================ */
@font-face {
    font-family: 'Material Icons';
    font-style: normal;
    font-weight: 400;
    src: url(https://fonts.gstatic.com/s/materialicons/v140/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2');
}

.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

/* ============================
   Chat Slide Panel
   ============================ */
.chat-slide-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 998;
    pointer-events: none;
    transition: background 0.3s ease;
}

.chat-slide-overlay.open {
    background: rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

.chat-slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    min-width: 320px;
    max-width: 95vw; /* Allow nearly full screen width */
    background: var(--bg-white, #ffffff);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Resize Handle */
.chat-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    background: transparent;
    z-index: 1001;
    transition: background 0.15s ease;
}

.chat-resize-handle:hover,
.chat-resize-handle:active {
    background: var(--primary-blue, #1976d2);
}

.chat-resize-handle::before {
    content: '';
    position: absolute;
    left: 1px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 48px;
    background: repeating-linear-gradient(
        to bottom,
        var(--text-tertiary, #9ca3af) 0px,
        var(--text-tertiary, #9ca3af) 2px,
        transparent 2px,
        transparent 6px
    );
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.chat-resize-handle:hover::before {
    opacity: 1;
}

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

.chat-slide-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.chat-slide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-blue, #1976d2) 0%, #1565c0 100%);
    color: white;
}

.chat-slide-header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-slide-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-slide-header-text {
    display: flex;
    flex-direction: column;
}

.chat-slide-title {
    font-weight: 600;
    font-size: var(--text-md);
}

.chat-slide-subtitle {
    font-size: var(--text-xs);
    opacity: 0.8;
}

.chat-slide-close {
    background: transparent;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.chat-slide-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-slide-stats {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-gray-50);
    border-bottom: 1px solid var(--border-light);
}

.chat-context-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #dbeafe, #e0f2fe);
    border-bottom: 1px solid #93c5fd;
    font-size: 0.75rem;
    color: #1e40af;
}

.chat-context-banner svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.chat-context-banner .chat-context-page {
    opacity: 0.7;
    font-style: italic;
}

/* Help Mode Header Actions */
.chat-slide-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chat-help-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-help-btn.active {
    background: rgba(255, 255, 255, 0.25);
}

.chat-help-btn .material-symbols-outlined {
    font-size: 20px;
}

/* Walkthrough Controls */
.chat-walkthrough-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border-bottom: 1px solid #6ee7b7;
}

.walkthrough-progress {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.walkthrough-step-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #065f46;
    opacity: 0.8;
}

.walkthrough-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #065f46;
}

.walkthrough-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.walkthrough-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(6, 95, 70, 0.1);
    color: #065f46;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.walkthrough-btn:hover:not(:disabled) {
    background: rgba(6, 95, 70, 0.2);
}

.walkthrough-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.walkthrough-btn.exit {
    background: rgba(185, 28, 28, 0.1);
    color: #991b1b;
}

.walkthrough-btn.exit:hover {
    background: rgba(185, 28, 28, 0.2);
}

.walkthrough-btn .material-symbols-outlined {
    font-size: 18px;
}

/* Quick Help Panel */
.chat-quick-help {
    padding: 1rem;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.quick-help-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.quick-help-header .material-symbols-outlined {
    color: #eab308;
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.quick-help-tour-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #1976d2, #1565c0);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-help-tour-btn:hover {
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.quick-help-tour-btn .material-symbols-outlined {
    font-size: 20px;
}

.quick-help-topics {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.quick-help-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 0.25rem;
}

.quick-help-topic {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-gray-50);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-help-topic:hover {
    background: var(--bg-gray-100);
    border-color: var(--border-med);
}

.quick-help-topic .material-symbols-outlined {
    font-size: 18px;
    color: #1976d2;
    flex-shrink: 0;
}

/* Dark mode for walkthrough/help */
[data-theme="dark"] .chat-walkthrough-controls {
    background: linear-gradient(135deg, #064e3b, #065f46);
    border-color: #047857;
}

[data-theme="dark"] .walkthrough-step-label,
[data-theme="dark"] .walkthrough-title {
    color: #a7f3d0;
}

[data-theme="dark"] .walkthrough-btn {
    background: rgba(167, 243, 208, 0.1);
    color: #a7f3d0;
}

[data-theme="dark"] .walkthrough-btn:hover:not(:disabled) {
    background: rgba(167, 243, 208, 0.2);
}

[data-theme="dark"] .walkthrough-btn.exit {
    background: rgba(254, 202, 202, 0.1);
    color: #fca5a5;
}

[data-theme="dark"] .walkthrough-btn.exit:hover {
    background: rgba(254, 202, 202, 0.2);
}

[data-theme="dark"] .chat-quick-help {
    background: var(--surface-card);
    border-color: var(--surface-border);
}

[data-theme="dark"] .quick-help-header {
    color: var(--text-secondary);
}

[data-theme="dark"] .quick-help-topic {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--surface-border);
    color: var(--text-primary);
}

[data-theme="dark"] .quick-help-topic:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .quick-help-topic .material-symbols-outlined {
    color: #64b5f6;
}

.chat-stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.35rem 0.5rem;
    background: var(--bg-white);
    border-radius: 6px;
    border: 1px solid var(--border-light);
}

.chat-stat-label {
    font-size: var(--text-2xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.chat-stat-value {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.chat-stat-value.budget {
    color: var(--success-green);
}

.chat-slide-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-gray-50);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-slide-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-tertiary);
    text-align: center;
    padding: 2rem;
}

.chat-empty-icon {
    opacity: 0.4;
}

.chat-empty-title {
    font-size: var(--text-md);
    font-weight: 500;
    color: var(--text-secondary);
}

.chat-empty-hint {
    font-size: var(--text-sm);
}

.chat-empty-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
    max-width: 100%;
}

.chat-empty-topic-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface-muted, #f3f4f6);
    border: 1px solid var(--surface-border, #e5e7eb);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.chat-empty-topic-btn:hover {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.25);
}

.chat-empty-topic-btn .material-symbols-outlined {
    font-size: 16px;
}

.chat-msg {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}

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

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-msg.user .chat-msg-avatar {
    background: var(--bg-gray-200);
    color: var(--text-secondary);
}

.chat-msg.assistant .chat-msg-avatar {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #1565c0 100%);
    color: white;
}

.chat-msg-content {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-msg.user .chat-msg-content {
    align-items: flex-end;
}

.chat-msg-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--text-xs);
}

.chat-msg-sender {
    font-weight: 500;
    color: var(--text-secondary);
}

.chat-msg-time {
    color: var(--text-tertiary);
}

.chat-msg-text {
    padding: 0.6rem 0.85rem;
    border-radius: 12px;
    font-size: var(--text-base);
    line-height: 1.5;
}

.chat-msg.user .chat-msg-text {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #1565c0 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant .chat-msg-text {
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px;
}

.chat-msg-text.markdown {
    padding: 0.6rem 0.85rem;
}

.chat-msg-text.markdown pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.5rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: var(--text-sm);
}

/* Markdown table styling */
.chat-msg-text.markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: var(--text-sm);
    background: var(--bg-white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chat-msg-text.markdown th,
.chat-msg-text.markdown td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.chat-msg-text.markdown th {
    background: var(--bg-gray-100);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.03em;
}

.chat-msg-text.markdown tr:last-child td {
    border-bottom: none;
}

.chat-msg-text.markdown tr:nth-child(even) {
    background: var(--bg-gray-50, #f8fafc);
}

.chat-msg-text.markdown tr:hover {
    background: var(--bg-gray-100);
}

/* Dark mode table styling */
[data-theme="dark"] .chat-msg-text.markdown table {
    background: var(--bg-gray-100);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .chat-msg-text.markdown th {
    background: var(--bg-gray-200);
    color: var(--text-primary);
}

[data-theme="dark"] .chat-msg-text.markdown th,
[data-theme="dark"] .chat-msg-text.markdown td {
    border-color: var(--border-medium);
}

[data-theme="dark"] .chat-msg-text.markdown tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .chat-msg-text.markdown tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Message action buttons container */
.chat-msg-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.chat-copy-btn,
.chat-view-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-copy-btn:hover,
.chat-view-toggle-btn:hover {
    background: var(--bg-gray-100);
    color: var(--text-secondary);
}

.chat-view-toggle-btn.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.chat-view-toggle-btn.active:hover {
    background: var(--primary-blue-hover);
}

/* Raw markdown view styling */
.chat-msg-raw {
    background: var(--bg-gray-50);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
}

.chat-msg-raw pre {
    margin: 0;
    padding: 0.75rem 1rem;
    background: transparent;
    overflow-x: auto;
}

.chat-msg-raw code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}

.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.75rem 1rem;
    background: var(--bg-white);
    border-radius: 12px;
    border: 1px solid var(--border-light);
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: chatTyping 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-slide-footer {
    padding: 0.75rem 1rem;
    background: var(--bg-white);
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-error {
    padding: 0.5rem 0.75rem;
    background: #fef2f2;
    color: var(--error-red);
    border-radius: 6px;
    font-size: var(--text-sm);
}

.chat-warning {
    padding: 0.4rem 0.6rem;
    background: #fffbeb;
    color: #b45309;
    border-radius: 4px;
    font-size: var(--text-xs);
}

.chat-prompt-dropdown {
    width: 100%;
    font-size: var(--text-sm);
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start; /* Keep send button at top when textarea expands */
}

.chat-textarea {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    resize: vertical; /* Allow vertical resizing */
    min-height: 42px; /* Minimum height (same as send button) */
    max-height: calc(50vh - 120px); /* Max ~50% of viewport minus header/footer space */
    outline: none;
    transition: border-color 0.15s ease;
}

.chat-textarea:focus {
    border-color: var(--primary-blue);
}

/* Resize handle indicator for textarea */
.chat-textarea::-webkit-resizer {
    background: linear-gradient(135deg, transparent 50%, var(--border-light) 50%);
    border-radius: 0 0 8px 0;
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--primary-blue);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--primary-blue-hover);
}

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

.chat-options-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.chat-toggle input {
    accent-color: var(--primary-blue);
}

.chat-reset-btn {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.chat-reset-btn:hover:not(:disabled) {
    background: var(--bg-gray-100);
    color: var(--text-secondary);
}

.chat-reset-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Save Prompt Button */
.chat-save-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.chat-save-btn:hover:not(:disabled) {
    background: var(--bg-gray-100);
    color: var(--primary-blue);
    border-color: var(--primary-blue);
}

.chat-save-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Save Prompt Modal */
.chat-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1100;
}

.chat-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 400px;
    max-width: 90vw;
    z-index: 1101;
    overflow: hidden;
}

.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-gray-50);
}

.chat-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-modal-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.chat-modal-close:hover {
    background: var(--bg-gray-100);
    color: var(--text-secondary);
}

.chat-modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.chat-modal-field > label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.chat-modal-field > label .required {
    color: var(--error-red);
}

.chat-modal-field > input[type="text"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-modal-field > input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-modal-field > input[type="text"]::placeholder {
    color: var(--text-muted);
}

.chat-modal-preview {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.chat-modal-preview > label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.chat-modal-preview-text {
    padding: 0.625rem 0.75rem;
    background: var(--bg-gray-50);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
    max-height: 80px;
    overflow: hidden;
    word-break: break-word;
}

.chat-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-light);
    background: var(--bg-gray-50);
}

.chat-modal-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-modal-btn.secondary {
    background: var(--bg-white);
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
}

.chat-modal-btn.secondary:hover:not(:disabled) {
    background: var(--bg-gray-50);
    border-color: var(--border-dark);
}

.chat-modal-btn.primary {
    background: var(--primary-blue);
    border: 1px solid var(--primary-blue);
    color: white;
}

.chat-modal-btn.primary:hover:not(:disabled) {
    background: var(--primary-blue-dark);
    border-color: var(--primary-blue-dark);
}

.chat-modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Prompts Row with Manage Button */
.chat-prompts-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-prompts-row .chat-prompt-dropdown {
    flex: 1;
}

.chat-manage-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: var(--bg-gray-100);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chat-manage-btn:hover {
    background: var(--primary-blue-light);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

/* Wide Modal */
.chat-modal-wide {
    max-width: 480px;
}

/* Manage Prompts Modal - Larger and Resizable */
.chat-modal-manage-prompts {
    width: 700px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    resize: both;
    overflow: auto;
    min-width: 400px;
    min-height: 300px;
}

.chat-modal-manage-prompts .chat-modal-body-scroll {
    flex: 1;
    max-height: none;
    overflow-y: auto;
}

.chat-modal-body-scroll {
    max-height: 400px;
    overflow-y: auto;
}

/* Stop/Cancel Button for AI Requests */
.chat-loading-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-stop-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: var(--text-xs);
    color: var(--error-red);
    background: transparent;
    border: 1px solid var(--error-red);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-stop-btn:hover {
    background: var(--error-red);
    color: white;
}

.chat-stop-btn svg {
    flex-shrink: 0;
}

/* Prompt Edit Textarea */
.chat-prompt-edit-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.chat-prompt-edit-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-white);
    resize: vertical;
    min-height: 100px;
    max-height: 300px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-prompt-edit-textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-prompt-edit-textarea::placeholder {
    color: var(--text-muted);
}

/* Empty State */
.chat-prompts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-tertiary);
}

.chat-prompts-empty svg {
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.chat-prompts-empty p {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.chat-prompts-empty-hint {
    font-size: 0.8rem;
}

/* Prompts List */
.chat-prompts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-prompt-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-gray-50);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-prompt-item:hover {
    background: var(--primary-blue-light);
    border-color: var(--primary-blue);
}

.chat-prompt-item.editing {
    background: var(--bg-white);
    border-color: var(--primary-blue);
    cursor: default;
}

.chat-prompt-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-prompt-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chat-prompt-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.chat-prompt-public {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-blue);
}

.chat-prompt-shared {
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.125rem 0.375rem;
    background: var(--warning-light);
    color: var(--warning-dark);
    border-radius: 4px;
}

.chat-prompt-category {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.chat-prompt-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Prompt Actions */
.chat-prompt-actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-shrink: 0;
}

.chat-prompt-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-prompt-action:hover:not(:disabled) {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.chat-prompt-action.delete:hover:not(:disabled) {
    border-color: var(--danger-red);
    color: var(--danger-red);
    background: rgba(239, 68, 68, 0.05);
}

.chat-prompt-action.use {
    background: var(--primary-blue-light);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.chat-prompt-action.use:hover {
    background: var(--primary-blue);
    color: white;
}

.chat-prompt-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Edit Form */
.chat-prompt-edit-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-prompt-edit-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-prompt-edit-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-white);
    transition: border-color 0.15s ease;
}

.chat-prompt-edit-input:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.chat-prompt-edit-input-sm {
    flex: 0 1 auto;
    max-width: 150px;
}

.chat-toggle-sm {
    font-size: 0.8rem;
}

.chat-prompt-edit-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

.chat-prompt-action-btn {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-prompt-action-btn.cancel {
    background: var(--bg-gray-100);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.chat-prompt-action-btn.cancel:hover:not(:disabled) {
    background: var(--bg-gray-200);
}

.chat-prompt-action-btn.save {
    background: var(--primary-blue);
    border: 1px solid var(--primary-blue);
    color: white;
}

.chat-prompt-action-btn.save:hover:not(:disabled) {
    background: var(--primary-blue-dark);
}

.chat-prompt-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Spinner */
.chat-prompt-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--border-light);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Header Chat Button */
.header-icon-btn--chat {
    position: relative;
}

.header-icon-btn--chat .chat-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--success-green);
    border-radius: 50%;
    border: 2px solid var(--bg-white);
}

/* Dark Mode for Chat Panel */
[data-theme="dark"] .chat-slide-panel {
    background: var(--bg-white);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .chat-slide-stats {
    background: var(--bg-gray-50);
    border-color: var(--border-light);
}

[data-theme="dark"] .chat-stat-item {
    background: var(--bg-gray-100);
    border-color: var(--border-light);
}

[data-theme="dark"] .chat-context-banner {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.2), rgba(14, 116, 144, 0.2));
    border-color: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

[data-theme="dark"] .chat-slide-body {
    background: var(--bg-main);
}

[data-theme="dark"] .chat-msg.assistant .chat-msg-text {
    background: var(--bg-gray-100);
    border-color: var(--border-light);
}

[data-theme="dark"] .chat-typing {
    background: var(--bg-gray-100);
    border-color: var(--border-light);
}

[data-theme="dark"] .chat-slide-footer {
    background: var(--bg-white);
    border-color: var(--border-light);
}

[data-theme="dark"] .chat-textarea {
    background: var(--bg-gray-100);
    border-color: var(--border-light);
    color: var(--text-primary);
}

[data-theme="dark"] .chat-textarea::-webkit-resizer {
    background: linear-gradient(135deg, transparent 50%, var(--border-light) 50%);
}

[data-theme="dark"] .chat-error {
    background: rgba(239, 68, 68, 0.15);
}

[data-theme="dark"] .chat-warning {
    background: rgba(245, 158, 11, 0.15);
}

/* Dark mode for raw markdown view and toggle button */
[data-theme="dark"] .chat-msg-raw {
    background: var(--bg-gray-100);
    border-color: var(--border-light);
}

[data-theme="dark"] .chat-msg-raw code {
    color: var(--text-primary);
}

[data-theme="dark"] .chat-view-toggle-btn:not(.active) {
    border-color: var(--border-light);
    color: var(--text-tertiary);
}

[data-theme="dark"] .chat-view-toggle-btn:not(.active):hover {
    background: var(--bg-gray-100);
    color: var(--text-secondary);
}

/* Dark mode for stop button */
[data-theme="dark"] .chat-stop-btn {
    color: #f87171;
    border-color: #f87171;
}

[data-theme="dark"] .chat-stop-btn:hover {
    background: #f87171;
    color: white;
}

/* Dark mode for prompt edit textarea */
[data-theme="dark"] .chat-prompt-edit-textarea {
    background: var(--bg-gray-100);
    border-color: var(--border-light);
    color: var(--text-primary);
}

[data-theme="dark"] .chat-prompt-edit-textarea:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(66, 165, 245, 0.2);
}

/* Dark mode for manage prompts modal */
[data-theme="dark"] .chat-modal-manage-prompts {
    background: var(--bg-gray-50);
    border-color: var(--border-light);
}

/* Responsive */
@media (max-width: 480px) {
    .chat-slide-panel {
        width: 100vw;
    }
}

/* ============================
   Data Grid Row Selection
   ============================ */
/* Custom and Radzen built-in selection highlighting */
.row-selected,
.rz-data-row.row-selected,
tr.row-selected,
tr.rz-data-row.row-selected,
.rz-datatable-tbody > tr.row-selected,
.rz-data-grid .rz-data-row.row-selected,
.rz-state-highlight,
tr.rz-state-highlight,
.rz-data-row.rz-state-highlight,
.rz-datatable-tbody > tr.rz-state-highlight,
.rz-data-grid .rz-data-row.rz-state-highlight {
    background-color: #e3f2fd !important;
    border-left: 3px solid var(--primary-blue) !important;
}

/* Target cells within selected rows */
.row-selected > td,
.rz-data-row.row-selected > td,
tr.row-selected > td,
.row-selected .rz-cell,
.rz-data-row.row-selected .rz-cell,
.rz-state-highlight > td,
.rz-data-row.rz-state-highlight > td,
tr.rz-state-highlight > td,
.rz-state-highlight .rz-cell,
.rz-data-row.rz-state-highlight .rz-cell {
    background-color: #e3f2fd !important;
}

.row-selected:hover,
.rz-data-row.row-selected:hover,
tr.row-selected:hover,
.rz-state-highlight:hover,
.rz-data-row.rz-state-highlight:hover,
tr.rz-state-highlight:hover {
    background-color: #bbdefb !important;
}

.row-selected:hover > td,
.rz-data-row.row-selected:hover > td,
tr.row-selected:hover > td,
.row-selected:hover .rz-cell,
.rz-data-row.row-selected:hover .rz-cell,
.rz-state-highlight:hover > td,
.rz-data-row.rz-state-highlight:hover > td,
tr.rz-state-highlight:hover > td,
.rz-state-highlight:hover .rz-cell,
.rz-data-row.rz-state-highlight:hover .rz-cell {
    background-color: #bbdefb !important;
}

[data-theme="dark"] .row-selected,
[data-theme="dark"] .rz-data-row.row-selected,
[data-theme="dark"] tr.row-selected,
[data-theme="dark"] .rz-state-highlight,
[data-theme="dark"] .rz-data-row.rz-state-highlight,
[data-theme="dark"] tr.rz-state-highlight {
    background-color: rgba(25, 118, 210, 0.25) !important;
    border-left: 3px solid var(--primary-blue) !important;
}

[data-theme="dark"] .row-selected > td,
[data-theme="dark"] .rz-data-row.row-selected > td,
[data-theme="dark"] tr.row-selected > td,
[data-theme="dark"] .row-selected .rz-cell,
[data-theme="dark"] .rz-data-row.row-selected .rz-cell,
[data-theme="dark"] .rz-state-highlight > td,
[data-theme="dark"] .rz-data-row.rz-state-highlight > td,
[data-theme="dark"] tr.rz-state-highlight > td,
[data-theme="dark"] .rz-state-highlight .rz-cell,
[data-theme="dark"] .rz-data-row.rz-state-highlight .rz-cell {
    background-color: rgba(25, 118, 210, 0.25) !important;
}

[data-theme="dark"] .row-selected:hover,
[data-theme="dark"] .rz-data-row.row-selected:hover,
[data-theme="dark"] tr.row-selected:hover,
[data-theme="dark"] .rz-state-highlight:hover,
[data-theme="dark"] .rz-data-row.rz-state-highlight:hover,
[data-theme="dark"] tr.rz-state-highlight:hover {
    background-color: rgba(25, 118, 210, 0.35) !important;
}

[data-theme="dark"] .row-selected:hover > td,
[data-theme="dark"] .rz-data-row.row-selected:hover > td,
[data-theme="dark"] tr.row-selected:hover > td,
[data-theme="dark"] .row-selected:hover .rz-cell,
[data-theme="dark"] .rz-data-row.row-selected:hover .rz-cell,
[data-theme="dark"] .rz-state-highlight:hover > td,
[data-theme="dark"] .rz-data-row.rz-state-highlight:hover > td,
[data-theme="dark"] tr.rz-state-highlight:hover > td,
[data-theme="dark"] .rz-state-highlight:hover .rz-cell,
[data-theme="dark"] .rz-data-row.rz-state-highlight:hover .rz-cell {
    background-color: rgba(25, 118, 210, 0.35) !important;
}
