/* Logo Icon for inmydata studio */
.logo-icon {
    width: 32px;
    height: 32px;
    vertical-align: middle;
    margin-right: 8px;
}

.logo-icon-large {
    width: 100px;
    height: 100px;
    vertical-align: middle;
    margin-right: 8px;
}

/* ========================================================================
   inmydata studio - Design System
   Full dark theme styling for the unified web frontend
   Updated color scheme: Red (#dd3333) + Teal (#2aa198)
   ======================================================================== */

/* ========================================================================
   CSS Variables - Design Tokens
   ======================================================================== */
:root {
    /* Colors - Dark Theme with Red + Teal accent scheme */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    /* Primary accent: Teal (for interactive elements, links, highlights) */
    --accent-primary: #2aa198;
    /* Secondary accent: Brand Red (for primary actions, branding) */
    --accent-secondary: #dd3333;
    /* Gradient uses brand red */
    --accent-gradient: linear-gradient(135deg, #dd3333 0%, #c12929 100%);
    
    /* Semantic colors */
    --success: #3fb950;
    --warning: #d4a02c;
    --error: #f85149;
    --info: #2aa198;
    
    /* Chart Color Palette - 8 colors for data visualization */
    --chart-1: #dd3333;  /* Brand Red */
    --chart-2: #2aa198;  /* Teal */
    --chart-3: #e8a525;  /* Gold/Amber */
    --chart-4: #5da5da;  /* Sky Blue */
    --chart-5: #60c689;  /* Mint Green */
    --chart-6: #a97bbb;  /* Lavender */
    --chart-7: #e07941;  /* Orange */
    --chart-8: #dc7c8a;  /* Coral Pink */
    
    --border: #30363d;
    --border-light: #21262d;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    
    /* Font Sizes */
    --font-xs: 12px;
    --font-sm: 13px;
    --font-base: 14px;
    --font-md: 16px;
    --font-lg: 18px;
    --font-xl: 20px;
    --font-2xl: 24px;
    --font-3xl: 32px;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Z-Index Layers */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 500;
    --z-toast: 1000;
}

/* ========================================================================
   Base Styles & Reset
   ======================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: var(--font-mono);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}

/* ========================================================================
   Global Scrollbar Styling
   ======================================================================== */
/* Custom scrollbar for all scrollable containers */
.message-container::-webkit-scrollbar,
.list-content::-webkit-scrollbar,
.chats-content::-webkit-scrollbar,
.drilldown-messages::-webkit-scrollbar,
.drilldown-table-wrapper::-webkit-scrollbar,
.nav-recents::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.message-container::-webkit-scrollbar-track,
.list-content::-webkit-scrollbar-track,
.chats-content::-webkit-scrollbar-track,
.drilldown-messages::-webkit-scrollbar-track,
.drilldown-table-wrapper::-webkit-scrollbar-track,
.nav-recents::-webkit-scrollbar-track {
    background: transparent;
}

.message-container::-webkit-scrollbar-thumb,
.list-content::-webkit-scrollbar-thumb,
.chats-content::-webkit-scrollbar-thumb,
.drilldown-messages::-webkit-scrollbar-thumb,
.drilldown-table-wrapper::-webkit-scrollbar-thumb,
.nav-recents::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.message-container::-webkit-scrollbar-thumb:hover,
.list-content::-webkit-scrollbar-thumb:hover,
.chats-content::-webkit-scrollbar-thumb:hover,
.drilldown-messages::-webkit-scrollbar-thumb:hover,
.drilldown-table-wrapper::-webkit-scrollbar-thumb:hover,
.nav-recents::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox scrollbar support */
.message-container,
.list-content,
.chats-content,
.drilldown-messages,
.drilldown-table-wrapper,
.nav-recents {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* ========================================================================
   Button Styles
   ======================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--font-base);
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    border: none;
    transition: all var(--transition-base);
}

/* display:inline-flex above overrides the browser's built-in
   [hidden] -> display:none, so hidden buttons stayed visible
   (e.g. Manage Subscription on partner accounts) */
.btn[hidden] {
    display: none !important;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: var(--space-sm);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.btn-icon:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--font-md);
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-sm);
}

.btn-danger {
    background: rgba(248, 81, 73, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(248, 81, 73, 0.2);
}

/* ========================================================================
   Form Elements
   ======================================================================== */
input, textarea, select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-base);
    width: 100%;
    transition: border-color var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    min-height: 44px;
}

/* ========================================================================
   Screen Layout System
   ======================================================================== */
.screen {
    display: none !important;
    height: 100vh;
}

.screen.active {
    display: flex !important;
    flex-direction: column;
}

.screen[hidden] {
    display: none !important;
}

/* ========================================================================
   Left Navigation Bar
   ======================================================================== */
.nav-bar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 56px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
    transition: width 250ms ease;
}

.nav-bar[hidden] {
    display: none !important;
}

.nav-bar.expanded {
    width: 260px;
}

.nav-bar.no-transition {
    transition: none;
}

/* Nav Toggle Button */
.nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.nav-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Nav Items */
.nav-items {
    display: flex;
    flex-direction: column;
    padding: var(--space-sm) 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-base);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-item[hidden] {
    display: none;
}

.nav-item i {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--font-lg);
}

.nav-item .nav-label {
    opacity: 0;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 200ms ease;
}

.nav-bar.expanded .nav-item .nav-label {
    opacity: 1;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-item.active {
    color: var(--accent-primary);
    background: rgba(42, 161, 152, 0.1);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-primary);
}

/* Nav Recents Section */
.nav-recents {
    flex: 1;
    overflow: hidden;
    padding: var(--space-md);
    border-top: 1px solid var(--border);
    margin-top: var(--space-sm);
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 200ms ease;
}

.nav-recents.visible {
    opacity: 1;
    visibility: visible;
}

.nav-recents-header {
    font-size: var(--font-xs);
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-sm);
}

.nav-recents-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-recent-item {
    margin-bottom: var(--space-xs);
}

.nav-recent-link {
    display: block;
    padding: var(--space-xs) var(--space-sm);
    color: var(--text-secondary);
    font-size: var(--font-sm);
    border-radius: var(--radius-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.nav-recent-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    text-decoration: none;
}

.nav-recents-empty {
    color: var(--text-muted);
    font-size: var(--font-sm);
    font-style: italic;
}

/* App Content - shifted by nav width */
.app-content {
    min-height: 100vh;
    transition: margin-left 250ms ease;
}

#nav-bar:not([hidden]) ~ .app-content {
    margin-left: 56px;
}

#nav-bar:not([hidden]) ~ .app-content.nav-expanded {
    margin-left: 260px;
}

.app-content.no-transition {
    transition: none;
}

/* ========================================================================
   Screen 1: Welcome
   ======================================================================== */
.welcome-screen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.welcome-container {
    text-align: center;
    max-width: 800px;
    padding: var(--space-xl);
}

.welcome-logo {
    font-size: 72px;
    margin-bottom: var(--space-md);
    animation: floatIn 0.6s ease-out;
}

@keyframes floatIn {
    from { 
        opacity: 0; 
        transform: translateY(-20px) scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.welcome-title {
    font-size: var(--font-3xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    font-size: var(--font-md);
}

.welcome-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.welcome-actions[hidden] {
    display: none !important;
}

.divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    color: var(--text-muted);
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.resume-section {
    display: flex;
    gap: var(--space-sm);
}

.resume-section select {
    flex: 1;
    cursor: pointer;
}

.resume-section input {
    flex: 1;
}

.nav-links {
    margin-top: var(--space-xl);
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-sm);
}

/* ========================================================================
   Screen 2: Chat Layout
   ======================================================================== */
.chat-screen {
    flex-direction: column;
}

/* Chat Header - Full Width */
.chat-header {
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--bg-secondary);
    flex-shrink: 0;
    height: 48px;
}

.chat-header h2 {
    flex: 1;
    font-size: var(--font-lg);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Chat Main Content Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.chat-panel {
    flex: 1;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-primary);
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    transition: all var(--transition-base);
}

.connection-status.status-connected {
    color: var(--success);
    opacity: 0.6;
}

.connection-status.status-connected:hover {
    opacity: 1;
}

.connection-status.status-connecting {
    color: var(--warning);
}

.connection-status.status-connecting .status-icon {
    animation: blink 1s ease-in-out infinite;
}

.connection-status.status-disconnected {
    color: var(--error);
}

.connection-status.status-offline {
    color: var(--text-muted);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Burger Menu & Dropdown */
.burger-menu {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-xs);
    min-width: 200px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    padding: var(--space-xs) 0;
    animation: dropdownIn 0.15s ease-out;
}

.dropdown-menu[hidden] {
    display: none;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-base);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast);
}

.menu-item:hover:not(:disabled) {
    background: var(--bg-secondary);
}

.menu-item:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.menu-item i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.menu-item:hover:not(:disabled) i {
    color: var(--text-primary);
}

.menu-item-danger {
    color: var(--error);
}

.menu-item-danger i {
    color: var(--error);
}

.menu-item-danger:hover:not(:disabled) {
    background: rgba(248, 81, 73, 0.1);
}

.menu-separator {
    height: 1px;
    background: var(--border);
    margin: var(--space-xs) 0;
}

/* Message Container */
.message-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    scroll-behavior: smooth;
}

/* Messages */
.message {
    display: flex;
    gap: var(--space-md);
    max-width: 85%;
    animation: messageIn 0.2s ease-out;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-user {
    align-self: flex-start;
    flex-direction: row;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-md);
    flex-shrink: 0;
}

.message-content {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    line-height: 1.6;
    word-wrap: break-word;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: var(--bg-tertiary);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}

/* Block elements produced by sanitizeMarkdown */
.message-content p {
    margin: 0 0 var(--space-sm) 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: var(--space-sm) 0 var(--space-xs) 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h3 { font-size: 1.15em; }
.message-content h4 { font-size: 1.05em; }
.message-content h5,
.message-content h6 { font-size: 1em; }

.message-content ul,
.message-content ol {
    margin: 0 0 var(--space-sm) 0;
    padding-left: 1.4em;
}

.message-content li {
    margin: 2px 0;
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-sm) 0;
}

.message-content a {
    color: var(--accent-primary);
    text-decoration: underline;
}

.message-content .md-table-wrap {
    overflow-x: auto;
    margin: 0 0 var(--space-sm) 0;
}

.message-content .md-table {
    border-collapse: collapse;
    font-size: 0.95em;
    min-width: 60%;
}

.message-content .md-table th,
.message-content .md-table td {
    border: 1px solid var(--border);
    padding: 4px 10px;
    text-align: left;
    white-space: nowrap;
}

.message-content .md-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-content .md-table tbody tr:nth-child(even) {
    background: var(--bg-tertiary);
}

.message-user .message-content {
    background: var(--accent-gradient);
    color: white;
}

.message-user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.message-system {
    align-self: center;
    max-width: 100%;
}

.message-system .message-content {
    background: transparent;
    color: var(--text-muted);
    font-size: var(--font-sm);
    text-align: center;
}

.message-error .message-content {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

/* Streaming cursor animation */
.message.streaming .message-content .streaming-dots {
    display: inline;
    margin-left: 4px;
}

.message.streaming .message-content .streaming-dots .dot {
    animation: dot-pulse 1.4s ease-in-out infinite;
    opacity: 0.3;
}

.message.streaming .message-content .streaming-dots .dot:nth-child(1) {
    animation-delay: 0s;
}

.message.streaming .message-content .streaming-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.message.streaming .message-content .streaming-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dot-pulse {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

/* Tool Status Indicator */
.tool-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin: var(--space-sm) var(--space-lg);
    font-size: var(--font-base);
    color: var(--text-secondary);
    animation: fadeIn 0.2s ease-out;
}

.tool-status[hidden] {
    display: none;
}

.tool-status .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-secondary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Pulse animation for tool status text */
.tool-status span:not(.spinner) {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Thinking Indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    color: var(--text-secondary);
    font-size: var(--font-base);
}

.thinking-indicator[hidden] {
    display: none;
}

.thinking-dots {
    display: flex;
    gap: 2px;
}

.thinking-dots span {
    animation: thinkingBounce 1.4s ease-in-out infinite;
    font-weight: bold;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingBounce {
    0%, 60%, 100% { 
        transform: translateY(0);
        opacity: 0.4;
    }
    30% { 
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Chat Input */
.chat-input-container {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat-input-form {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-end;
}

.chat-input-form textarea {
    flex: 1;
    resize: none;
    min-height: 44px;
    max-height: 150px;
    line-height: 1.4;
}

/* Speech Recognition Button */
.btn-speech {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-speech:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.btn-speech.listening {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
    color: white;
    animation: pulse-recording 1.5s ease-in-out infinite;
}

.btn-speech.listening:hover {
    background: #c53030;
    border-color: #c53030;
}

.btn-speech:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-speech[hidden] {
    display: none;
}

@keyframes pulse-recording {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(229, 62, 62, 0);
    }
}

/* ========================================================================
   Panel Divider (Draggable)
   ======================================================================== */
.panel-divider {
    width: 6px;
    background: var(--border);
    cursor: col-resize;
    transition: background 0.15s ease;
    flex-shrink: 0;
    align-self: stretch;
}

.panel-divider:hover,
.panel-divider.dragging {
    background: var(--accent-primary);
}

.panel-divider[hidden] {
    display: none;
}

/* ========================================================================
   Right Panel (Screens 3, 4, 5)
   ======================================================================== */
.right-panel {
    width: 45%;
    max-width: 700px;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    animation: slideIn 0.25s ease-out;
}

.right-panel[hidden] {
    display: none;
}

@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-content[hidden] {
    display: none;
}

.panel-header {
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
}

.panel-header h3 {
    font-size: var(--font-md);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.panel-frame {
    flex: 1;
    border: none;
    background: var(--bg-tertiary);
}

.panel-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    text-align: center;
}

.panel-hint {
    color: var(--text-secondary);
    font-size: var(--font-base);
}

/* Building Content (Screen 4) */
.building-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.spinner-large {
    width: 56px;
    height: 56px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-secondary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
    margin-bottom: var(--space-lg);
}

.progress-bar {
    width: 80%;
    max-width: 300px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-text {
    color: var(--text-secondary);
    font-size: var(--font-base);
}

/* Complete Content (Screen 5) */
.complete-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.complete-actions {
    padding: var(--space-md) var(--space-lg);
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
}

/* Error Content */
.error-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    text-align: center;
}

.error-icon {
    font-size: 56px;
    margin-bottom: var(--space-md);
    animation: shake 0.5s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.error-message {
    color: var(--error);
    font-size: var(--font-md);
    margin-bottom: var(--space-sm);
    max-width: 400px;
}

.error-attempts {
    color: var(--text-secondary);
    font-size: var(--font-base);
    margin-bottom: var(--space-lg);
}

.error-actions {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.error-hint {
    color: var(--text-muted);
    font-size: var(--font-sm);
    max-width: 300px;
}

/* ========================================================================
   Screen 6: Dashboard List (with inline viewer)
   ======================================================================== */
.list-screen {
    flex-direction: column;
    background: var(--bg-primary);
}

/* Grid View Container */
.list-grid-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.list-grid-view[hidden] {
    display: none;
}

.list-header {
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    height: 48px;
    flex-shrink: 0;
}

.list-header h2 {
    flex: 1;
    font-size: var(--font-lg);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.list-subtitle {
    display: none; /* Hidden for compact header */
}

.search-box {
    flex: 1;
    max-width: 400px;
}

.list-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
}

/* Inline Dashboard Viewer */
.list-dashboard-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.list-dashboard-view[hidden] {
    display: none;
}

.inline-dashboard-header {
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    height: 48px;
}

.inline-dashboard-header h2 {
    flex: 1;
    font-size: var(--font-lg);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inline-dashboard-actions {
    display: flex;
    gap: var(--space-sm);
}

.inline-dashboard-frame {
    flex: 1;
    border: none;
    background: white;
}

/* ========================================================================
   Screen 7: Chats List
   ======================================================================== */
.chats-screen {
    flex-direction: column;
    background: var(--bg-primary);
}

.chats-header {
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    height: 48px;
    flex-shrink: 0;
}

.chats-header-top {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 1;
}

.chats-header-top h2 {
    font-size: var(--font-lg);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.chats-header-bottom {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.chats-header-bottom .search-box {
    width: 250px;
}

.chat-count {
    color: var(--text-secondary);
    font-size: var(--font-sm);
    white-space: nowrap;
}

.chats-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
}

/* Chat Grid - Tile Layout */
.chats-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
}

/* Chat Item Card */
.chat-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition-base);
    animation: cardIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 140px;
}

.chat-item:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.chat-item-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: var(--accent-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--font-xl);
    flex-shrink: 0;
    margin-bottom: var(--space-md);
}

.chat-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-item-title {
    font-weight: 600;
    font-size: var(--font-md);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    min-height: 38px;
}

.chat-item-meta {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.chat-item-delete {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all var(--transition-fast);
    font-size: var(--font-md);
}

.chat-item:hover .chat-item-delete {
    opacity: 1;
}

.chat-item-delete:hover {
    color: var(--error);
    background: rgba(248, 81, 73, 0.15);
}

/* Empty state for chats */
.chats-empty {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
    position: absolute;
    left: 0px;
    right: 0px;
    margin-inline: auto;
}

.chats-empty-icon {
    font-size: 64px;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.chats-empty-title {
    font-size: var(--font-lg);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.chats-empty-description {
    margin-bottom: var(--space-lg);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
}

/* Dashboard Card */
.dashboard-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border);
    transition: all var(--transition-base);
    animation: cardIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    height: 100%;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dashboard-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: var(--font-md);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.card-description {
    color: var(--text-secondary);
    font-size: var(--font-base);
    margin-bottom: var(--space-md);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 44px;
    flex: 1;
}

.card-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.card-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: auto;
}

/* Loading Skeleton */
.dashboard-card.skeleton {
    pointer-events: none;
}

.dashboard-card.skeleton .card-title,
.dashboard-card.skeleton .card-description,
.dashboard-card.skeleton .card-meta {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    color: transparent;
}

.dashboard-card.skeleton .card-title {
    width: 60%;
    height: 20px;
}

.dashboard-card.skeleton .card-description {
    width: 100%;
    height: 44px;
}

.dashboard-card.skeleton .card-meta {
    width: 40%;
    height: 14px;
}

.dashboard-card.skeleton .card-actions {
    visibility: hidden;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
    position: absolute;
    left: 0px;
    right: 0px;
    margin-inline: auto;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--font-lg);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.empty-state-description {
    margin-bottom: var(--space-lg);
}

/* ========================================================================
   Screen 7: Dashboard Display (Deprecated - kept for backwards compatibility)
   ======================================================================== */
.dashboard-screen {
    flex-direction: column;
}

.dashboard-view-header {
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    height: 48px;
}

.dashboard-view-header h2 {
    flex: 1;
    font-size: var(--font-lg);
    font-weight: 600;
}

.dashboard-actions {
    display: flex;
    gap: var(--space-sm);
}

.dashboard-frame {
    flex: 1;
    border: none;
    background: white;
}

/* ========================================================================
   Toast Notifications
   ======================================================================== */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease-out;
    max-width: 380px;
    pointer-events: auto;
}

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.hiding {
    animation: toastOut 0.3s ease-out forwards;
}

@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-success {
    border-color: var(--success);
    background: #1a2e1f;
}

.toast-warning {
    border-color: var(--warning);
    background: #2e2714;
}

.toast-error {
    border-color: var(--error);
    background: #2e1a19;
}

.toast-info {
    border-color: var(--info);
    background: #162b29;
}

.toast-icon {
    font-size: var(--font-lg);
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: var(--font-base);
    color: var(--text-primary);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    font-size: var(--font-md);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* ========================================================================
   Confirm Modal
   ======================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    min-width: 320px;
    max-width: 420px;
    z-index: calc(var(--z-modal) + 1);
    box-shadow: var(--shadow-lg);
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base), transform var(--transition-base);
}

.modal-container.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    color: var(--warning);
}

.modal-danger .modal-icon {
    color: var(--error);
}

.modal-info .modal-icon {
    color: var(--info);
}

.modal-title {
    font-size: var(--font-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.modal-message {
    font-size: var(--font-base);
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

.modal-actions .btn {
    min-width: 100px;
}

/* Connection Delete Modal Styles */
.deletion-list {
    list-style: none;
    padding-left: 0;
    margin: var(--space-md) 0;
    max-height: 300px;
    overflow-y: auto;
}

.deletion-list li {
    padding: var(--space-sm);
    margin: var(--space-xs) 0;
    background: rgba(212, 160, 44, 0.15); /* Warning color with opacity */
    border-left: 3px solid var(--warning);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    color: var(--text-primary);
}

.deletion-list li strong {
    color: var(--text-primary);
}

.warning-text {
    color: var(--error);
    font-weight: 500;
    margin: var(--space-md) 0;
    padding: var(--space-md);
    background: rgba(248, 81, 73, 0.1); /* Error color with opacity */
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--error);
    font-size: var(--font-sm);
    line-height: 1.5;
}

/* ========================================================================
   Responsive Design
   ======================================================================== */
@media (max-width: 1024px) {
    .chat-panel {
        min-width: 350px;
    }
    
    .right-panel {
        width: 50%;
        min-width: 300px;
    }
}

@media (max-width: 768px) {
    :root {
        --font-base: 15px;
    }
    
    .chat-main {
        flex-direction: column;
    }
    
    .chat-panel {
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        height: 55vh;
    }
    
    .right-panel {
        width: 100%;
        max-width: none;
        min-width: auto;
        height: 45vh;
    }
    
    /* Dashboard list header - wrap search below */
    .list-header {
        flex-wrap: wrap;
        padding: var(--space-sm) var(--space-md);
        height: auto;
        min-height: 48px;
    }
    
    .list-header .search-box {
        order: 3;
        max-width: 100%;
        flex-basis: 100%;
        margin-top: var(--space-sm);
    }
    
    /* Chats header - wrap search below like list header */
    .chats-header {
        flex-wrap: wrap;
        padding: var(--space-sm) var(--space-md);
        height: auto;
        min-height: 48px;
    }
    
    .chats-header-bottom {
        order: 3;
        flex-basis: 100%;
        margin-top: var(--space-sm);
    }
    
    .chats-header-bottom .search-box {
        flex: 1;
        width: auto;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .chats-list {
        grid-template-columns: 1fr;
    }

    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
        top: auto;
        bottom: var(--space-lg);
    }
    
    .toast {
        max-width: 100%;
    }
    
    .modal-container {
        min-width: auto;
        max-width: calc(100% - var(--space-xl));
        padding: var(--space-lg);
    }
    
    .modal-icon {
        font-size: 40px;
    }
    
    .welcome-container {
        padding: var(--space-lg);
    }
    
    .welcome-title {
        font-size: var(--font-2xl);
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: var(--space-sm) var(--space-md);
        gap: var(--space-sm);
    }
    
    .chat-header h2 {
        font-size: var(--font-md);
    }
    
    .message-container {
        padding: var(--space-md);
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-input-container {
        padding: var(--space-sm) var(--space-md);
    }
    
    .panel-header,
    .panel-footer {
        padding: var(--space-md);
    }
}

/* ========================================================================
   Utility Classes
   ======================================================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hidden {
    display: none !important;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #6e7681;
        --text-secondary: #c9d1d9;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================================================
   Drill-Down Modal
   ======================================================================== */
.drilldown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.drilldown-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.drilldown-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90vw;
    height: 90vh;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.2s, opacity 0.2s, visibility 0.2s;
}

.drilldown-container.visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.drilldown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.drilldown-header-actions {
    display: flex;
    gap: var(--space-sm);
}

.drilldown-breadcrumbs {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-sm);
    flex-wrap: wrap;
}

.drilldown-breadcrumb {
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.drilldown-breadcrumb:hover:not(.active) {
    color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.drilldown-breadcrumb:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.drilldown-breadcrumb.active {
    color: var(--text-primary);
    font-weight: 500;
    cursor: default;
}

.drilldown-breadcrumb-separator {
    color: var(--text-muted);
}

.drilldown-close,
.drilldown-reset,
.drilldown-feedback {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.drilldown-close:hover,
.drilldown-reset:hover,
.drilldown-feedback:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.drilldown-close:focus,
.drilldown-reset:focus,
.drilldown-feedback:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.drilldown-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.drilldown-chat {
    width: 35%;
    min-width: 300px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.drilldown-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    scroll-behavior: smooth;
}

/* Drilldown messages - matching main chat styles */
.drilldown-message {
    display: flex;
    gap: var(--space-md);
    max-width: 85%;
    animation: messageIn 0.2s ease-out;
}

.drilldown-message.user {
    align-self: flex-start;
    flex-direction: row;
}

.drilldown-message.assistant {
    align-self: flex-start;
    flex-direction: row;
}

.drilldown-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-md);
    flex-shrink: 0;
    color: var(--text-secondary);
}

.drilldown-message-content {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    line-height: 1.6;
    word-wrap: break-word;
}

.drilldown-message-content strong {
    font-weight: 600;
}

.drilldown-message-content em {
    font-style: italic;
}

.drilldown-message-content code {
    background: var(--bg-tertiary);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}

/* User message styling - gradient background matching main chat */
.drilldown-message.user .drilldown-message-content {
    background: var(--accent-gradient);
    color: white;
}

.drilldown-message.user .drilldown-message-content code {
    background: rgba(255, 255, 255, 0.2);
}

/* System message styling - centered, subtle */
.drilldown-message.system {
    align-self: center;
    max-width: 100%;
}

.drilldown-message.system .drilldown-message-avatar {
    display: none;
}

.drilldown-message.system .drilldown-message-content {
    background: transparent;
    color: var(--text-muted);
    font-size: var(--font-sm);
    text-align: center;
    padding: var(--space-sm);
}

/* Error message styling */
.drilldown-message.error .drilldown-message-content {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

/* Streaming cursor animation for drilldown */
.drilldown-message.streaming .drilldown-message-content .streaming-dots {
    display: inline;
    margin-left: 4px;
}

.drilldown-message.streaming .drilldown-message-content .streaming-dots .dot {
    animation: dot-pulse 1.4s ease-in-out infinite;
    opacity: 0.3;
}

/* Typing indicator - matching main chat thinking indicator */
.drilldown-typing {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-md) var(--space-md) 0;
    max-width: 85%;
    animation: messageIn 0.2s ease-out;
}

.drilldown-typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-md);
    flex-shrink: 0;
    color: var(--text-secondary);
}

.drilldown-typing-avatar i {
    animation: fa-beat 1.2s ease-in-out infinite;
}

.drilldown-typing-dots {
    display: flex;
    gap: 2px;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.drilldown-typing-dots span {
    animation: thinkingBounce 1.4s ease-in-out infinite;
    font-weight: bold;
    color: var(--text-secondary);
}

.drilldown-typing-dots span:nth-child(1) { animation-delay: 0s; }
.drilldown-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.drilldown-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Suggestions - displayed above input area */
.drilldown-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-primary);
}

.drilldown-suggestion {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
    text-align: left;
}

.drilldown-suggestion:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    transform: translateY(-1px);
}

.drilldown-suggestion:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.drilldown-suggestion strong {
    font-size: var(--font-sm);
    color: var(--text-primary);
}

.drilldown-suggestion span {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.drilldown-input-area {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    align-items: flex-end;
}

.drilldown-input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-base);
    font-family: var(--font-family);
    min-height: 44px;
    line-height: 1.4;
}

.drilldown-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.drilldown-input::placeholder {
    color: var(--text-muted);
}

.drilldown-input:disabled,
.drilldown-input.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* drilldown-send uses btn btn-primary classes, just add disabled state */
.drilldown-send:disabled,
.drilldown-send.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Light theme for drilldown chart area - matches dashboard styling */
.drilldown-chart {
    width: 65%;
    display: flex;
    flex-direction: column;
    padding: var(--space-lg);
    overflow: hidden;
    background: #f0f2f5;
    
    /* Light theme CSS variables for charts */
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --text-primary: #1a1a2e;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border: #e9ecef;
}

.drilldown-chart-title {
    font-size: var(--font-lg);
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: #1a1a2e;
}

.drilldown-chart-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: var(--space-lg);
}

.drilldown-chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

.drilldown-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    color: #666666;
}

.drilldown-loading .spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--accent-secondary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

/* Drilldown table styles - light theme matching dashboards */
.drilldown-table-wrapper {
    width: 100%;
    max-height: 100%;
    overflow: auto;
    background: white;
    border-radius: 8px;
}

.drilldown-table-wrapper .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-sm);
}

.drilldown-table-wrapper .data-table th,
.drilldown-table-wrapper .data-table td {
    padding: 12px var(--space-md);
    text-align: left;
}

.drilldown-table-wrapper .data-table th {
    background: #f8f9fa;
    color: #333333;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    position: sticky;
    top: 0;
}

.drilldown-table-wrapper .data-table td {
    color: #666666;
    border-bottom: 1px solid #e9ecef;
}

.drilldown-table-wrapper .data-table tbody tr:hover {
    background: #f8f9fa;
}

.drilldown-chart .chart-error {
    color: #c00000;
    padding: var(--space-lg);
    text-align: center;
    background: #fff5f5;
    border-radius: 8px;
}

/* Responsive */
@media (max-width: 900px) {
    .drilldown-container {
        width: 95vw;
        height: 90vh;
    }
    
    .drilldown-body {
        flex-direction: column;
    }
    
    .drilldown-chat {
        width: 100%;
        height: 40%;
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .drilldown-chart {
        width: 100%;
        height: 60%;
    }
}

/* ========================================================================
   Authentication UI (Phase 2)
   ======================================================================== */

/* Nav User Section - positioned at bottom of nav bar */
.nav-user {
    margin-top: auto;
    padding: var(--space-sm);
    border-top: 1px solid var(--border);
}

/* User Info Display */
.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    margin-bottom: var(--space-xs);
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 200ms ease;
}

.nav-bar.expanded .user-info {
    opacity: 1;
    visibility: visible;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: var(--font-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Login/Logout Buttons */
.nav-login,
.nav-logout {
    margin-top: var(--space-xs);
}

.nav-login i,
.nav-logout i {
    color: var(--text-secondary);
}

.nav-login:hover i {
    color: var(--accent-primary);
}

.nav-logout:hover i {
    color: var(--error);
}

/* No Account Warning Banner */
.warning-banner {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(212, 160, 44, 0.15);
    border-bottom: 1px solid var(--warning);
    color: var(--warning);
    font-size: var(--font-sm);
}

.warning-banner[hidden] {
    display: none !important;
}

.warning-banner i {
    flex-shrink: 0;
}

.warning-banner a {
    color: var(--warning);
    font-weight: 500;
    text-decoration: underline;
}

.warning-banner a:hover {
    color: var(--text-primary);
}

/* Info Banner (e.g., trial ending) */
.info-banner {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(42, 161, 152, 0.15);
    border-bottom: 1px solid var(--info);
    color: var(--info);
    font-size: var(--font-sm);
}

.info-banner[hidden] {
    display: none !important;
}

.info-banner i {
    flex-shrink: 0;
}

.info-banner a {
    color: var(--info);
    font-weight: 500;
    text-decoration: underline;
}

.info-banner a:hover {
    color: var(--text-primary);
}

/* Error Banner (e.g., suspended) */
.error-banner {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(248, 81, 73, 0.15);
    border-bottom: 1px solid var(--error);
    color: var(--error);
    font-size: var(--font-sm);
}

.error-banner[hidden] {
    display: none !important;
}

.error-banner i {
    flex-shrink: 0;
}

.error-banner a {
    color: var(--error);
    font-weight: 500;
    text-decoration: underline;
}

.error-banner a:hover {
    color: var(--text-primary);
}

/* Responsive: Show user info only when nav expanded */
@media (max-width: 768px) {
    .user-info {
        display: none;
    }
}
/* =============================================================================
   Welcome Screen - Unauthenticated State
   ============================================================================= */
.welcome-description {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

.auth-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 3rem;
}

.auth-buttons .btn-lg {
    min-width: 150px;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
}

.feature-item i {
    font-size: 2rem;
    color: var(--primary);
}

.feature-item span {
    color: var(--text-primary);
    font-size: 1rem;
}

@media (max-width: 768px) {
    .auth-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .auth-buttons .btn-lg {
        width: 100%;
    }
    
    .welcome-features {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}


/* ============================================================================
   Subscription Selection Screen
   ============================================================================ */

/* Screen Reader Only Content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.subscribe-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    padding: 2rem;
}

.subscribe-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.subscribe-header-actions {
    display: flex;
    gap: var(--space-sm);
}

/* ========================================================================
   Super-admin impersonation banner
   ======================================================================== */
.impersonation-banner {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1300;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-md);
    background: repeating-linear-gradient(
        45deg,
        #4a3800,
        #4a3800 10px,
        #3d2e00 10px,
        #3d2e00 20px
    );
    color: var(--warning);
    border: 1px solid var(--warning);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-size: var(--font-sm);
    box-shadow: var(--shadow-lg);
}

.impersonation-banner .btn {
    padding: 2px var(--space-sm);
    font-size: var(--font-xs);
}

/* An author-level `display` beats the UA stylesheet's [hidden] rule, so the
   banner needs this to stay hidden when not impersonating (house pattern -
   see .warning-banner[hidden] etc.) */
.impersonation-banner[hidden] {
    display: none !important;
}

.subscribe-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.subscribe-logo i {
    font-size: 2rem;
}

.subscribe-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.subscribe-content h1 {
    font-size: 2.5rem;
    color: #fff;
}

.subscribe-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Billing Toggle */
.billing-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.toggle-label {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.2s;
}

.toggle-label.active {
    color: #fff;
}

.badge-save {
    background: var(--success);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 32px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #30363d;
    border-radius: 32px;
    transition: background-color 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 4px;
    bottom: 4px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(28px);
}

/* Plan Cards */
.plan-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.plan-card {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 80px 70px 180px 190px auto;
    background: #161b22;
    border: 2px solid #30363d;
    border-radius: 12px;
    padding: 2rem;
    text-align: left;
    position: relative;
    transition: all 0.3s;
}

.plan-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(88, 166, 255, 0.2);
}

.plan-card-featured {
    border-color: var(--primary);
}

.plan-badge {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.375rem 1rem;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.plan-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.plan-price {
    margin-bottom: 1.5rem;
    padding: 1.5rem 0;
    border-top: 1px solid #30363d;
    border-bottom: 1px solid #30363d;
}

.price-amount {
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
}

.price-amount-small {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.price-period {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

.price-billing {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.price-per-user {
    min-height: 31px;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.price-total {
    margin-top: 0.5rem;
}

/* Team Size Selector */
.team-size-selector {
    margin-bottom: 1.5rem;
}

.team-size-placeholder {
    min-height: 48px;
}

.team-size-selector label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.number-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.number-input input {
    width: 80px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 0.5rem;
    color: #fff;
}

.btn-decrement,
.btn-increment {
    width: 36px;
    height: 36px;
    background: #30363d;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-decrement:hover,
.btn-increment:hover {
    background: #484f58;
}

.btn-decrement:disabled,
.btn-increment:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Plan Features */
.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    color: var(--text-secondary);
}

.plan-features i {
    color: var(--success);
    font-size: 1rem;
}

.plan-select {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
}

/* Loading States */
.pricing-loading,
.subscribe-loading {
    margin-top: 3rem;
    padding: 2rem;
    text-align: center;
}

.pricing-loading i,
.subscribe-loading i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.pricing-loading p,
.subscribe-loading p {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .subscribe-content h1 {
        font-size: 2rem;
    }

    .plan-cards {
        grid-template-columns: 1fr;
        max-width: 400px;
    }
    
    .billing-toggle {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ============================================================================
   Post-Checkout Loading Screen
   ============================================================================ */

.post-checkout-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.post-checkout-content {
    text-align: center;
    max-width: 500px;
}

.loading-icon {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 2rem;
}

.post-checkout-content h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #fff;
}

.post-checkout-content p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
    text-align: left;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.progress-step.active {
    border-left-color: var(--success);
}

.progress-step i {
    font-size: 1.5rem;
    width: 24px;
}

.progress-step .fa-check-circle {
    color: var(--success);
}

.progress-step .fa-spinner {
    color: var(--primary);
}

.progress-step .fa-circle {
    color: var(--text-secondary);
}

.progress-step span {
    color: var(--text-secondary);
}

.progress-step.active span {
    color: #fff;
    font-weight: 500;
}

.progress-note {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

.timeout-warning {
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(255, 193, 7, 0.1);
    border-left: 3px solid #ffc107;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.timeout-warning i {
    color: #ffc107;
    font-size: 1.5rem;
}

.timeout-warning p {
    margin: 0;
    color: #ffc107;
}

#btn-retry-provisioning {
    margin-top: 1.5rem;
}

/* ========================================================================
   No Connections State - Disabled navigation and banner
   ======================================================================== */

/* Disabled navigation items */
.nav-item[disabled],
.nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* No connections banner */
#no-connections-banner {
    background: var(--warning-bg, #fff3cd);
    border-left: 4px solid var(--warning, #d4a02c);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
}

#no-connections-banner .warning-content {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

#no-connections-banner i {
    font-size: 1.5rem;
    color: var(--warning, #d4a02c);
    margin-top: 0.25rem;
}

#no-connections-banner .warning-text h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

#no-connections-banner .warning-text p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary, #8b949e);
}

/* ========================================================================
   Token Usage - Billing Screen
   ======================================================================== */

.token-usage-summary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.usage-period {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.usage-period i {
    color: var(--accent-primary);
}

.usage-progress {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.usage-label {
    font-weight: 600;
    color: var(--text-primary);
}

.usage-value {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.usage-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.usage-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.usage-detail-row span:first-child {
    color: var(--text-secondary);
}

.usage-detail-row span:last-child {
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
}

.overage-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: 6px;
}

.overage-warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--error);
    font-weight: 600;
}

.overage-warning i {
    font-size: 1.1rem;
}

.cost-highlight {
    color: var(--error);
    font-weight: 600;
}

.usage-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(42, 161, 152, 0.1);
    border: 1px solid rgba(42, 161, 152, 0.3);
    border-radius: 6px;
    color: var(--text-secondary);
}

.usage-alert i {
    color: var(--accent-primary);
    margin-top: 0.15rem;
}

.usage-alert p {
    margin: 0;
    font-size: 0.9rem;
}

.info-message,
.error-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 6px;
}

.info-message {
    background: rgba(42, 161, 152, 0.1);
    border: 1px solid rgba(42, 161, 152, 0.3);
    color: var(--text-secondary);
}

.info-message i {
    color: var(--accent-primary);
}

.error-message {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--text-secondary);
}

.error-message i {
    color: var(--error);
}

.info-message p,
.error-message p {
    margin: 0;
    font-size: 0.9rem;
}

/* Overage Settings Form */
.form-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-primary);
}

.form-group-toggle:last-of-type {
    border-bottom: none;
}

.toggle-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toggle-label strong {
    color: var(--text-primary);
}

.toggle-label small {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform 0.2s;
}

input[type="checkbox"]:checked + .toggle-switch {
    background: var(--accent-primary);
}

input[type="checkbox"]:checked + .toggle-switch::after {
    transform: translateX(24px);
}

/* Hide checkbox visually but keep it accessible - scoped to toggle-switch sibling only */
input[type="checkbox"]:has(+ .toggle-switch) {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Ensure parent label contains absolutely positioned checkbox */
label:has(> input[type="checkbox"] + .toggle-switch) {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Toast notifications */
.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideInRight 0.3s ease;
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-error {
    border-left: 3px solid var(--error);
}

.toast-fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ============================================================================
   Dashboard sharing: card badges and the share dialog
   ============================================================================ */

/* .menu-item is display:flex, which beats the UA [hidden] rule */
.menu-item[hidden] {
    display: none !important;
}

.card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.access-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: rgba(139, 148, 158, 0.2);
    color: var(--text-secondary);
}

.access-badge.private {
    background: rgba(139, 148, 158, 0.2);
    color: var(--text-secondary);
}

.access-badge.team {
    background: rgba(42, 161, 152, 0.2);
    color: var(--accent-primary);
}

.access-badge.shared {
    background: rgba(42, 161, 152, 0.12);
    color: var(--accent-primary);
}

.access-badge.owner {
    background: rgba(221, 51, 51, 0.2);
    color: var(--accent-secondary);
}

.access-badge.level {
    text-transform: none;
    font-weight: 400;
}

.share-dialog .modal-content h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.share-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-sm);
    margin: 0 0 var(--space-md);
}

.share-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: 50vh;
    overflow-y: auto;
}

.share-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.share-row-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1 1 auto;
    min-width: 0;
}

.share-row-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.share-row-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.share-row-title {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-row-subtitle {
    font-size: var(--font-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The global `select { width: 100% }` rule would push the grantee's name
   out of the row; keep the selector a fixed column on the right instead */
.share-row .share-level-select {
    flex: 0 0 auto;
    width: 170px;
    min-width: 170px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--font-sm);
}

.share-empty {
    color: var(--text-muted);
    font-size: var(--font-sm);
    padding: var(--space-sm) 0;
}

.share-legend {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: var(--space-md) 0 0;
    font-size: var(--font-xs);
    color: var(--text-muted);
}
