/* ========================================
   QueBot - Estilos Principales
   Inspirado en Tasklet UI
   ======================================== */

:root {
    /* Light theme */
    --bg-primary: #F7F8FA;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f1f3;
    --bg-hover: #e8e9ec;
    --bg-active: #e8edf4;
    
    --text-primary: #1C1E21;
    --text-secondary: #5F6368;
    --text-tertiary: #9ca3af;
    --text-inverse: #ffffff;
    
    --border-color: #e5e7eb;
    --border-focus: #3b82f6;
    
    --accent-primary: #1F3A5F;
    --accent-primary-hover: #162d4a;
    --accent-secondary: #3b82f6;
    --accent-orange: #f97316;
    
    --message-user-bg: rgba(31, 58, 95, 0.85);
    --message-user-text: #ffffff;
    --message-bot-bg: #ffffff;
    --message-bot-text: #1C1E21;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 6px 18px rgba(0, 0, 0, 0.06);
    
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 0px;
    --preview-width: 400px;
    --header-height: 60px;
    --input-height: 80px;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #171717;
    --bg-tertiary: #262626;
    --bg-hover: #333333;
    --bg-active: #1e3a5f;
    
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #6b7280;
    --text-inverse: #111827;
    
    --border-color: #333333;
    --border-focus: #60a5fa;
    
    --accent-primary: #4a7ab5;
    --accent-primary-hover: #3d6b9e;
    
    --message-user-bg: rgba(31, 58, 95, 0.85);
    --message-user-text: #ffffff;
    --message-bot-bg: #262626;
    --message-bot-text: #f9fafb;
}

/* ========================================
   Reset & Base
   ======================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

textarea {
    font-family: inherit;
    resize: none;
}

/* ========================================
   App Container
   ======================================== */

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
}

/* ========================================
   Sidebar
   ======================================== */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: min-width var(--transition-normal), width var(--transition-normal);
    z-index: 100;
    overflow: hidden;
}

.sidebar.collapsed {
    min-width: 0;
    width: 0;
}

/* When sidebar is collapsed, show the menu button in header (all screen sizes) */
.sidebar.collapsed ~ .sidebar-overlay ~ .main-content .mobile-menu-btn,
.sidebar.collapsed ~ .main-content .mobile-menu-btn {
    display: flex;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--accent-primary);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    background: var(--accent-orange);
    color: white;
    border-radius: var(--radius-full);
    text-transform: lowercase;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px;
    padding: 12px 16px;
    background: rgba(31,58,95,0.08);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

[data-theme="dark"] .new-chat-btn {
    background: rgba(74,122,181,0.1);
}

.new-chat-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.new-chat-btn svg {
    width: 18px;
    height: 18px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.history-section {
    margin-bottom: 16px;
}

.history-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 8px 4px;
}

.history-items {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.71rem;
    transition: all var(--transition-fast);
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.history-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.history-item.active {
    background: var(--bg-active);
    color: var(--accent-secondary);
}

.history-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.history-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-delete {
    opacity: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.history-item:hover .history-item-delete {
    opacity: 1;
}

.history-item-delete:hover {
    background: var(--bg-tertiary);
    color: #ef4444;
}

.history-item-delete svg {
    width: 14px;
    height: 14px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

[data-theme="light"] .moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.user-info:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-name {
    font-weight: 500;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========================================
   Main Content
   ======================================== */

.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-width: 0;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ========================================
   Chat Header
   ======================================== */

.chat-header {
    height: var(--header-height);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    gap: 12px;
}

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: var(--bg-hover);
}

.mobile-menu-btn svg {
    width: 22px;
    height: 22px;
}

.chat-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.chat-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.action-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

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

.action-btn.active {
    background: var(--bg-active);
    color: var(--accent-secondary);
}

.action-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Messages Area
   ======================================== */

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    padding: 60px 40px 40px;
    max-width: 1170px;
    margin: 0 auto;
    width: 100%;
}

.welcome-screen.hidden {
    display: none;
}

/* ========================================
   Dashboard: Hero Section
   ======================================== */

.hero-section {
    text-align: center;
    margin-bottom: 64px;
    width: 100%;
}

.hero-title {
    font-size: 40px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.15;
    margin-bottom: 16px;
}

.hero-subtitle {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 540px;
    margin: 0 auto;
}

/* ========================================
   Dashboard: Quick Actions (Block A)
   ======================================== */

.dashboard-section {
    width: 100%;
    margin-bottom: 64px;
}

.dashboard-section:last-child {
    margin-bottom: 40px;
}

.section-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    text-align: center;
    min-height: 120px;
    justify-content: center;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.action-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
}

.action-card-icon svg {
    width: 24px;
    height: 24px;
}

.action-card-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.action-card-desc {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Action card colored accents by type */
.action-card[data-card-type="news"] { border-top: 3px solid #3b82f6; }
.action-card[data-card-type="prices"] { border-top: 3px solid #10b981; }
.action-card[data-card-type="property"] { border-top: 3px solid #f97316; }
.action-card[data-card-type="analysis"] { border-top: 3px solid #8b5cf6; }
.action-card[data-card-type="code"] { border-top: 3px solid #06b6d4; }

.action-card[data-card-type="news"] .action-card-icon { color: #3b82f6; }
.action-card[data-card-type="prices"] .action-card-icon { color: #10b981; }
.action-card[data-card-type="property"] .action-card-icon { color: #f97316; }
.action-card[data-card-type="analysis"] .action-card-icon { color: #8b5cf6; }
.action-card[data-card-type="code"] .action-card-icon { color: #06b6d4; }

/* ========================================
   Filter Buttons (Card Flow)
   ======================================== */

.filter-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.filter-btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    font-family: inherit;
}

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

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

/* ========================================
   Dashboard: How It Works (Block B)
   ======================================== */

.how-it-works {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.how-step {
    text-align: center;
    padding: 24px 16px;
}

.how-step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    margin: 0 auto 16px;
}

.how-step h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.how-step p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ========================================
   Dashboard: Recent Cases (Block C)
   ======================================== */

.recent-cases-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.case-card {
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    text-align: left;
    transition: all 0.2s ease;
}

.case-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.case-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.case-card-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.case-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-tertiary);
}

.case-card-status {
    padding: 2px 8px;
    border-radius: 9999px;
    background: var(--bg-tertiary);
    font-size: 11px;
    font-weight: 500;
}

.no-cases-msg {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
    padding: 40px 0;
}

/* ========================================
   Dashboard: Capabilities (Block D)
   ======================================== */

.capabilities-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.capability-item {
    padding: 10px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.capability-item:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1040px;
    margin: 0 auto;
    width: 100%;
}

/* ========================================
   Message Bubbles
   ======================================== */

.message {
    display: flex;
    gap: 12px;
    animation: messageIn 0.3s ease;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.875rem;
}

.message.user .message-avatar {
    background: var(--accent-primary);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.message.assistant .message-avatar svg {
    width: 20px;
    height: 20px;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.message-author {
    font-weight: 600;
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.message-body {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    line-height: 1.6;
    overflow-wrap: break-word;
    word-break: break-word;
}

.message.user .message-body {
    background: var(--message-user-bg);
    color: var(--message-user-text);
    border-bottom-left-radius: var(--radius-sm);
}

.message.assistant .message-body {
    background: var(--message-bot-bg);
    color: var(--message-bot-text);
    border-bottom-left-radius: var(--radius-sm);
}

/* Markdown content in messages */
.message-body h1, .message-body h2, .message-body h3 {
    margin: 16px 0 8px;
    font-weight: 600;
}

.message-body h1:first-child,
.message-body h2:first-child,
.message-body h3:first-child {
    margin-top: 0;
}

.message-body p {
    margin: 8px 0;
}

.message-body p:first-child {
    margin-top: 0;
}

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

.message-body ul, .message-body ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-body li {
    margin: 4px 0;
}

.message-body code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.875em;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
}

.message.user .message-body code {
    background: rgba(255, 255, 255, 0.15);
}

.message-body pre {
    margin: 12px 0;
    padding: 16px;
    background: #1e1e1e;
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.message-body pre code {
    background: none;
    padding: 0;
    color: #e5e5e5;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.message-body blockquote {
    margin: 12px 0;
    padding: 12px 16px;
    border-left: 4px solid var(--accent-primary);
    background: var(--bg-tertiary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Table wrapper for horizontal scroll */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 12px 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.message-body table {
    width: 100%;
    min-width: 400px;
    margin: 0;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.message-body th, .message-body td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

.message-body th {
    background: var(--bg-tertiary);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.message-body a {
    color: var(--accent-secondary);
    text-decoration: none;
}

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

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: var(--radius-full);
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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


/* Thinking indicator - animated steps */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.thinking-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: thinkingSpin 0.8s linear infinite;
    flex-shrink: 0;
}

.thinking-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
    transition: opacity 0.2s ease;
}

@keyframes thinkingSpin {
    to { transform: rotate(360deg); }
}
/* ========================================
   Input Area
   ======================================== */

.input-area {
    padding: 16px 20px 20px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.input-container {
    max-width: 1040px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--border-focus);
}

.attach-btn, .send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.attach-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.attach-btn svg, .send-btn svg {
    width: 20px;
    height: 20px;
}

.send-btn {
    background: var(--accent-primary);
    color: white;
    opacity: 0.5;
}

.send-btn:not(:disabled) {
    opacity: 1;
}

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

.message-input {
    flex: 1;
    min-height: 40px;
    max-height: 200px;
    padding: 10px 4px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
    outline: none;
    min-width: 0;
}

.message-input::placeholder {
    color: var(--text-tertiary);
}

.attached-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.attached-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.attached-file svg {
    width: 14px;
    height: 14px;
}

.attached-file-remove {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--text-tertiary);
}

.attached-file-remove:hover {
    background: var(--bg-hover);
    color: #ef4444;
}

.input-disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 10px;
}

/* ========================================
   Preview Panel (Render Sidebar)
   ======================================== */

.preview-panel {
    width: var(--preview-width);
    min-width: var(--preview-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    position: absolute;
    right: 0;
    top: 0;
    z-index: 90;
}

.preview-panel.open {
    transform: translateX(0);
    position: relative;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.preview-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.close-preview {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.close-preview:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.close-preview svg {
    width: 18px;
    height: 18px;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.preview-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-tertiary);
}

.preview-placeholder svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.preview-placeholder p {
    font-size: 0.875rem;
}

/* ========================================
   Loading & Toast
   ======================================== */

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

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

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

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

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: calc(100vw - 48px);
}

.toast.error {
    border-color: #ef4444;
    background: #fef2f2;
}

[data-theme="dark"] .toast.error {
    background: #450a0a;
}

.toast.success {
    border-color: #22c55e;
    background: #f0fdf4;
}

[data-theme="dark"] .toast.success {
    background: #052e16;
}

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

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast.error .toast-icon {
    color: #ef4444;
}

.toast.success .toast-icon {
    color: #22c55e;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
}

.toast-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
}

.toast-close:hover {
    background: var(--bg-hover);
}

.toast-close svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   Sidebar Overlay (Mobile)
   ======================================== */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.visible {
    display: block;
}

/* ========================================
   Auth Modal
   ======================================== */

.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.auth-modal-content h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.auth-modal-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.auth-email {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.auth-btn {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

.auth-btn.google {
    background: #ffffff;
    color: #333;
    border: 1px solid var(--border-color);
}

.auth-btn.google:hover {
    background: #f5f5f5;
}

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

.auth-btn.primary:hover {
    background: var(--accent-primary-hover);
}

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

.auth-btn.secondary:hover {
    background: var(--bg-hover);
}

.auth-note {
    font-size: 0.75rem !important;
    color: var(--text-tertiary) !important;
    margin-top: 16px !important;
}

/* ========================================
   Enhanced Table Styling (Property Cards)
   ======================================== */

.message-body tr:nth-child(even) {
    background: var(--bg-tertiary);
}

.message-body tr:hover {
    background: var(--bg-hover);
    transition: background 0.15s ease;
}

.message-body td:first-child {
    font-weight: 550;
}

/* ========================================
   Property Portal Link Badges
   ======================================== */

.portal-badge {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
    font-weight: 600;
    vertical-align: middle;
    line-height: 1.6;
}

/* ========================================
   Section Headers Enhancement (Phase 6)
   ======================================== */

.message.assistant .message-body h2 {
    border-left: 4px solid var(--accent-primary);
    padding-left: 12px;
    margin-top: 20px;
    margin-bottom: 10px;
}

.message.assistant .message-body h3 {
    border-left: 3px solid var(--accent-secondary);
    padding-left: 10px;
    margin-top: 16px;
    margin-bottom: 8px;
}

/* ========================================
   Risk Flag Styling
   ======================================== */

.risk-flag {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid #f59e0b;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 4px 0;
}

[data-theme="dark"] .risk-flag {
    background: rgba(245, 158, 11, 0.08);
}

/* ========================================
   Calibration Question Styling
   ======================================== */

.message.assistant .message-body ol li {
    padding: 2px 0;
}

/* Quick Reply Suggestion Buttons */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 60px;
    animation: fadeSlideUp 0.3s ease-out;
}

.quick-reply-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-reply-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

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

/* ========================================
   Login Prompt Button (Header)
   ======================================== */

.login-prompt-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.login-prompt-btn:hover {
    background: var(--accent-primary-hover);
    transform: scale(1.03);
}

.login-prompt-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ========================================
   How It Works — Colored Step Numbers
   ======================================== */

.how-step:nth-child(1) .how-step-number { background: #3b82f6; }
.how-step:nth-child(2) .how-step-number { background: #8b5cf6; }
.how-step:nth-child(3) .how-step-number { background: #10b981; }

/* ========================================
   Responsive Design - Tablet
   ======================================== */

@media (max-width: 1024px) {
    .preview-panel {
        width: 100%;
        min-width: 100%;
    }
    
    .preview-panel.open {
        position: absolute;
    }
}

/* ========================================
   Responsive Design - Mobile
   ======================================== */

@media (max-width: 768px) {
    /* Sidebar: fixed overlay, hidden by default */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px;
        min-width: 280px;
        z-index: 200;
        transform: translateX(-280px);
        box-shadow: none;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    
    /* On mobile, collapsed sidebar stays hidden via transform */
    .sidebar.collapsed {
        width: 280px;
        min-width: 280px;
        transform: translateX(-280px);
    }
    
    /* Hamburger menu button always visible on mobile */
    .mobile-menu-btn {
        display: flex;
    }
    
    /* Chat header */
    .chat-header {
        padding: 0 12px;
        gap: 8px;
    }
    
    .chat-title {
        font-size: 0.9rem;
    }
    
    /* Messages area */
    .messages-area {
        padding: 12px;
    }
    
    .messages-list {
        gap: 16px;
    }
    
    /* Message layout */
    .message {
        gap: 8px;
    }
    
    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
    
    .message-body {
        padding: 10px 14px;
        font-size: 0.875rem;
    }
    
    .message-author {
        font-size: 0.8rem;
    }
    
    /* Tables: allow horizontal scroll */
    .message-body table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    .message-body th, .message-body td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    /* Code blocks: scroll */
    .message-body pre {
        padding: 12px;
        font-size: 0.75rem;
    }
    
    /* Input area */
    .input-area {
        padding: 8px 12px 12px;
    }
    
    .input-wrapper {
        padding: 6px 8px;
        gap: 4px;
    }
    
    .message-input {
        font-size: 16px; /* Prevents iOS zoom */
        min-height: 36px;
        padding: 8px 4px;
    }
    
    .attach-btn, .send-btn {
        width: 36px;
        height: 36px;
    }
    
    .input-disclaimer {
        font-size: 0.7rem;
        margin-top: 6px;
    }
    
    /* Dashboard responsive */
    .welcome-screen {
        padding: 32px 20px 24px;
    }
    
    .hero-section {
        margin-bottom: 32px;
    }
    
    .hero-title {
        font-size: 26px;
        background: linear-gradient(135deg, var(--accent-primary), #3b82f6);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }
    
    .dashboard-section {
        margin-bottom: 32px;
    }
    
    .quick-actions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .action-card {
        flex-direction: row;
        align-items: center;
        text-align: left;
        padding: 12px;
        font-size: 0.8rem;
        min-height: 56px;
        gap: 10px;
    }
    
    .action-card .action-card-icon {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }
    
    .action-card .action-card-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .action-card .action-card-desc {
        font-size: 10px;
    }
    
    .filter-buttons-row {
        gap: 6px;
    }
    
    .filter-btn {
        padding: 5px 12px;
        font-size: 12px;
    }
    
    .how-it-works {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .how-step {
        padding: 16px;
    }
    
    .recent-cases-grid {
        grid-template-columns: 1fr;
    }
    
    .new-chat-btn {
        margin: 12px;
    }
    
    /* Preview panel: fullscreen overlay on mobile */
    .preview-panel {
        position: fixed;
        top: 0;
        right: 0;
        width: 100vw;
        min-width: 100vw;
        height: 100vh;
        height: 100dvh;
        z-index: 300;
        transform: translateX(100%);
    }
    
    .preview-panel.open {
        position: fixed;
        transform: translateX(0);
    }

    /* Preview close: larger touch target on mobile */
    .close-preview {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    

    /* Auth modal: ensure centered on mobile */
    .auth-modal {
        padding: 16px;
    }
    
    .auth-modal-content {
        max-width: 320px;
    }

    /* Toast notifications */
    .toast-container {
        bottom: 80px;
        right: 12px;
        left: 12px;
    }
    
    .toast {
        max-width: 100%;
    }
}

/* ========================================
   Small phones
   ======================================== */

@media (max-width: 480px) {
    .quick-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 380px) {
    .login-prompt-btn span {
        display: none; /* just show icon on very small screens */
    }
    
    .login-prompt-btn {
        padding: 6px 8px;
    }
    
    .chat-header {
        padding: 0 8px;
    }
    
    .chat-title {
        font-size: 0.85rem;
    }
    
    .action-btn {
        width: 32px;
        height: 32px;
    }
    
    .action-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .message-body {
        padding: 8px 12px;
        font-size: 0.8125rem;
    }
}

/* ========================================
   Scrollbar Styling
   ======================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Mobile: thin scrollbars */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}

/* ================================================
   SSE Thinking Log — Real pipeline steps
   ================================================ */
.thinking-log {
    padding: 4px 0;
    max-width: 480px;
}

.thinking-log-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.thinking-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary, #6b7280);
    opacity: 0;
    animation: fadeInStep 0.35s ease forwards;
}

.thinking-step .step-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
}

.thinking-step.completed .step-icon {
    color: #22c55e;
}

.thinking-step.active {
    color: var(--text-primary, #1f2937);
    font-weight: 500;
}

.thinking-step.active .step-icon {
    color: var(--accent-color, #1a5f2a);
}

.step-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(128,128,128,0.2);
    border-top-color: var(--accent-color, #1a5f2a);
    border-radius: 50%;
    animation: spinStep 0.7s linear infinite;
    display: inline-block;
}

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

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

/* Dark mode adjustments */
[data-theme="dark"] .thinking-step {
    color: rgba(255,255,255,0.5);
}

[data-theme="dark"] .thinking-step.active {
    color: rgba(255,255,255,0.9);
}

[data-theme="dark"] .thinking-step.completed .step-icon {
    color: #4ade80;
}

[data-theme="dark"] .step-spinner {
    border-color: rgba(255,255,255,0.1);
    border-top-color: #4ade80;
}

/* Mobile: slightly smaller */
@media (max-width: 768px) {
    .thinking-log {
        max-width: 100%;
    }
    .thinking-step {
        font-size: 12px;
        gap: 8px;
    }
}

/* === Voice Input === */
.voice-mic-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.voice-mic-btn svg {
    width: 20px;
    height: 20px;
}

.voice-mic-btn:hover {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.voice-mic-btn.listening {
    color: #ef4444;
    animation: pulse-mic 1.5s ease-in-out infinite;
    background: rgba(239, 68, 68, 0.1);
}

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

/* TTS button on messages */
.tts-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.message:hover .tts-btn {
    opacity: 0.7;
}

.tts-btn:hover {
    opacity: 1;
    background: rgba(99, 102, 241, 0.1);
}

.tts-btn.speaking {
    opacity: 1;
    color: var(--accent);
}
