/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* ==========================================================================
     DESIGN SYSTEM TOKENS
     Based on the Updated Design Guide
     ========================================================================== */

  /* Brand Colors (Primary Accent) - Teal */
  --primary: #0D9488;           /* Primary / 1 - Default accent */
  --primary-hover: #14B8A6;     /* Primary / 2 - Hover states */
  --primary-active: #2DD4BF;    /* Primary / 3 - Active/pressed */
  --primary-disabled: #CCFBF1;  /* Primary / 4 - Disabled */
  --primary-light: #14B8A6;     /* Alias for compatibility */
  --primary-dark: #0F766E;      /* Darker shade */
  --primary-lighter: #F0FDFA;   /* Ultra-light background */

  /* RGB values for rgba() usage */
  --primary-rgb: 13, 148, 136;
  --primary-hover-rgb: 20, 184, 166;
  --primary-active-rgb: 45, 212, 191;

  /* Text Colors */
  --text-header: #1B1C20;       /* Header - Main headings */
  --text-body: #383A47;         /* Body - Primary paragraph text */
  --text-muted: #70727F;        /* Body 2 - Secondary/subtitles */
  --text-tertiary: #CDCED8;     /* Body 3 - Hints/placeholders/disabled */
  --text-on-color: #FFFFFF;     /* Text on dark backgrounds */

  /* Compatibility aliases */
  --text: var(--text-body);
  --text-primary: var(--text-header);
  --text-secondary: var(--text-muted);
  --dark: var(--text-header);
  --dark-light: var(--text-body);

  /* Background Colors */
  --bg-dark: #474958;           /* Background / 1 - Cards, sidebars, dark sections */
  --bg-light: #E8E9ED;          /* Background / 2 - Containers, forms, panels */
  --bg-ultra-light: #F8F8FA;    /* Background / 3 - Page background */
  --white: #FFFFFF;
  --light: var(--bg-ultra-light);

  /* Compatibility aliases */
  --bg-primary: var(--white);
  --bg-secondary: var(--bg-ultra-light);

  /* Border Colors */
  --border: #CDCED8;            /* Light borders */
  --border-light: #E8E9ED;      /* Ultra-light borders */
  --border-dark: #70727F;       /* Dark borders */
  --border-color: var(--border);

  /* Semantic Colors */
  --secondary: #70727F;
  --success: #10b981;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;

  /* Secondary Accent (use sparingly) */
  --accent-pink: #DF678C;
  --accent-pink-hover: #D84773;

  /* ==========================================================================
     STANDARDIZED SCALES
     ========================================================================== */

  /* Border Radius Scale */
  --radius-2xs: 4px;            /* Very small elements, tags */
  --radius-xs: 6px;             /* Small buttons, inputs */
  --radius-sm: 8px;             /* Inputs, badges, small elements */
  --radius-md: 10px;            /* Medium elements */
  --radius-lg: 12px;            /* Buttons, cards */
  --radius-xl: 14px;            /* Large elements */
  --radius-2xl: 16px;           /* Modals, panels */
  --radius-3xl: 20px;           /* Extra large elements */
  --radius-full: 999px;         /* Pills, avatars */

  /* Z-index Scale */
  --z-base: 1;
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-modal-backdrop: 2000;
  --z-modal: 2001;
  --z-toast: 3000;
  --z-tooltip: 4000;

  /* Font Size Scale - Complete */
  --text-2xs: 10px;    /* Tiny labels, badges */
  --text-xs: 11px;     /* Small badges, hints */
  --text-sm: 12px;     /* Small text, captions */
  --text-md: 13px;     /* Secondary body text */
  --text-base: 14px;   /* Primary body text */
  --text-lg: 15px;     /* Emphasized body */
  --text-xl: 16px;     /* Subheadings */
  --text-2xl: 18px;    /* Section headings */
  --text-3xl: 20px;    /* Page subheadings */
  --text-4xl: 24px;    /* Page headings */
  --text-5xl: 28px;    /* Large headings */
  --text-6xl: 32px;    /* Hero text */
  --text-7xl: 48px;    /* Display text */

  /* Spacing Scale - Complete */
  --space-0: 0px;
  --space-px: 1px;
  --space-0-5: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-2-5: 10px;
  --space-3: 12px;
  --space-3-5: 14px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Layout */
  --sidebar-width: 260px;
}

html {
  /* Always show scrollbar to prevent layout shift when navigating between pages */
  overflow-y: scroll;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--light);
  color: var(--text);
  line-height: 1.6;
}

/* ==========================================================================
   AUTH GUARD - Prevents flash of protected content before auth verification
   ========================================================================== */

/* Pages with auth-protected class hide content by default */
body.auth-protected {
  visibility: hidden;
}

/* Content becomes visible once auth is verified */
body.auth-protected.auth-verified {
  visibility: visible;
}

/* Also hide during the checking phase (redundant but explicit) */
body.auth-protected.auth-checking {
  visibility: hidden;
}

/* Loading indicator while checking auth (optional - can be customized) */
body.auth-protected:not(.auth-verified)::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--light);
  z-index: 99999;
  visibility: visible;
}

/* Login Page Styles */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: var(--space-5);
}

.login-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-10);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 420px;
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-header h1 {
  font-size: var(--text-5xl);
  color: var(--dark);
  margin-bottom: var(--space-2);
}

.login-header p {
  color: var(--text-muted);
  font-size: var(--text-base);
}

.form-group {
  margin-bottom: var(--space-6);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  font-size: var(--text-base);
  color: var(--dark);
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-lg);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  font-family: inherit;
  background: var(--white);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 109, 38, 171), 0.1);
  background: var(--white);
}

.form-control:hover {
  border-color: var(--primary-light);
}

.btn {
  display: inline-block;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-on-color);
  width: 100%;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:active {
  background: var(--primary-active);
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.2);
}

.btn-primary:disabled {
  background: var(--primary-disabled);
  color: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--bg-ultra-light);
  border-color: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-on-color);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: var(--danger-hover);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.btn-xs {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-md);
  font-weight: 500;
}

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  position: relative;
  z-index: var(--z-toast);
  white-space: pre-line;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Toast Notifications - floating, compact alerts */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--background);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  min-width: 200px;
  pointer-events: auto;
  animation: toast-slide-in 0.3s ease;
  border-left: 4px solid var(--text-muted);
}

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

.toast.toast-error {
  border-left-color: var(--danger);
  background: #fef2f2;
}

.toast.toast-info {
  border-left-color: var(--primary);
  background: #eff6ff;
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  color: #1f2937 !important;
}

.toast-icon {
  color: #1f2937 !important;
}

.toast.toast-success .toast-icon {
  color: #059669 !important;
}

.toast.toast-error .toast-icon {
  color: #dc2626 !important;
}

.toast.toast-info .toast-icon {
  color: #2563eb !important;
}

.toast-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #6b7280;
  font-size: 16px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toast-close:hover {
  opacity: 1;
}

.toast.toast-exit {
  animation: toast-slide-out 0.2s ease forwards;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Dark mode toast */
[data-theme="dark"] .toast {
  background: var(--background-secondary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

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

[data-theme="dark"] .toast.toast-info {
  background: #172554;
}

[data-theme="dark"] .toast .toast-message,
[data-theme="dark"] .toast .toast-icon,
html[data-theme="dark"] .toast .toast-message,
html[data-theme="dark"] .toast .toast-icon,
.dark .toast .toast-message,
.dark .toast .toast-icon {
  color: #f3f4f6 !important;
}

[data-theme="dark"] .toast .toast-close,
html[data-theme="dark"] .toast .toast-close,
.dark .toast .toast-close {
  color: #9ca3af !important;
}

/* Form Helper Styles */
.form-text {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.required {
  color: var(--danger);
  font-weight: 600;
}

/* Password Strength Indicator */
.password-strength {
  margin-top: var(--space-2);
}

.strength-bar {
  width: 100%;
  height: 4px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-1);
}

.strength-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease, background-color 0.3s ease;
  border-radius: var(--radius-full);
}

/* Login/Signup Footer */
.login-footer {
  margin-top: var(--space-5);
  text-align: center;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

.login-footer p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.login-footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* OAuth Divider */
.oauth-divider {
  display: flex;
  align-items: center;
  margin: var(--space-5) 0;
}

.oauth-divider::before,
.oauth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.oauth-divider span {
  padding: 0 var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-transform: lowercase;
}

/* Google Sign-In Button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: 12px 16px;
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-google:hover {
  background: var(--bg-light);
  border-color: var(--border-medium);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btn-google:active {
  transform: scale(0.98);
}

.btn-google svg {
  flex-shrink: 0;
}

/* Dashboard Layout */
.dashboard {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--dark);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
}

.sidebar-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ============================================
   APP BRANDING SECTION (Primary - Always Same)
   ============================================ */
.app-branding {
  display: flex;
  align-items: center;  /* Vertically center logo and text */
  gap: 12px;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-logo {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-logo svg {
  display: block;  /* Remove inline spacing */
}

.app-title {
  display: flex;
  flex-direction: column;
  justify-content: center;  /* Center text vertically */
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.app-title h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  padding: 0;
  letter-spacing: -0.4px;
  line-height: 1.3;  /* Better vertical alignment */
  color: #FFFFFF;  /* White text for app name */
}

.app-title p {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);  /* Muted white for subtitle */
  margin: 0;
  padding: 0;
  line-height: 1.2;
  font-weight: 500;
}

/* ============================================
   TEAM CONTEXT SECTION (Secondary - Changes)
   ============================================ */
.team-context {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.team-context-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  opacity: 0.7;
}

.team-selector {
  display: flex !important;
  flex-direction: row !important;  /* Ensure items are in a row */
  align-items: center !important;  /* Vertically center avatar and text */
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  transition: background 0.2s ease;
  cursor: pointer;
  position: relative;
}

.team-selector:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Team switcher dropdown */
.team-switcher-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #2a2d3a;
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.team-switcher-dropdown.show {
  display: block;
}

.team-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.team-switcher-item:hover {
  background: rgba(13, 148, 136, 0.1);
}

.team-switcher-item.active {
  background: rgba(13, 148, 136, 0.15);
}

.team-switcher-item .team-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.team-switcher-item .team-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

.team-switcher-item.active .team-name {
  color: #0D9488;
  font-weight: 600;
}

.team-switcher-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Dropdown arrow indicator */
.team-selector::after {
  content: '▼';
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  margin-left: auto;
  transition: transform 0.2s ease;
}

.team-selector.open::after {
  transform: rotate(180deg);
}

.team-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.2), rgba(15, 118, 110, 0.2));
  border-radius: var(--radius);
  border: 1.5px solid rgba(13, 148, 136, 0.3);
  position: relative;  /* For absolute positioning of children */
}

.team-avatar-fallback {
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hide fallback when custom logo is loaded */
.team-avatar img.team-logo-img,
.team-avatar img.team-avatar-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.team-info {
  display: flex;
  flex-direction: column;
  justify-content: center;  /* Center text vertically */
  gap: 2px;
  flex: 1 1 auto;  /* Allow shrinking */
  min-width: 0;  /* Allow text truncation */
  max-width: 100%;  /* Don't overflow container */
}

.team-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;  /* Better alignment */
  color: #FFFFFF;  /* White text to match */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  padding: 0;
}

/* ============================================
   LEGACY STYLES (Keep for backward compat)
   ============================================ */
.sidebar-header-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-header-title {
  display: flex;
  flex-direction: column;
  gap: var(--space-px);
  flex: 1;
  min-width: 0;
}

.sidebar-header h2 {
  font-size: var(--text-base);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.3px;
  line-height: 1;
}

.sidebar-header p {
  font-size: var(--text-2xs);
  color: rgba(255, 255, 255, 0.4);
  margin: 0;
  line-height: 1;
}

/* Team info row - shows team name and status */
.team-info-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.team-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  flex: 1;
  min-width: 0;
}

.team-name-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  min-width: 0;
  padding: var(--space-1) var(--space-2);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xs);
  transition: background 0.2s;
}

.team-name-badge:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* DEPRECATED: Duplicate .team-name rule - using the one in TEAM CONTEXT SECTION above (line 461) */
/*
.team-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
*/

/* Status indicator - shows pending items count */
.header-status-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  padding: var(--space-0-5) var(--space-1-5);
  border-radius: var(--radius-2xs);
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
  overflow-y: auto;
}

/* Navigation divider between regular and admin sections */
.nav-divider {
  margin: var(--space-3) var(--space-4);
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  padding: var(--space-2-5) var(--space-4);
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  font-size: var(--text-base);
  font-weight: 500;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0 var(--space-1) var(--space-1) 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 1);
  border-left-color: rgba(255, 255, 255, 0.3);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.15);
  border-left-color: var(--primary);
  color: rgba(255, 255, 255, 1);
  font-weight: 600;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.user-info {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.user-info:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-lg);
  margin-right: var(--space-3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.user-details {
  min-width: 0;
  flex: 1;
}

.user-details h4 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-0-5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.4;
}

.user-details p {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  line-height: 1.3;
}

/* Sidebar Logout Button - Fixed for visibility */
.sidebar-footer .btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  padding: var(--space-2-5) var(--space-4);
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.sidebar-footer .btn-secondary:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.sidebar-footer .btn-secondary:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.12);
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: var(--space-6) var(--space-8);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  /* Removed max-width constraint - let content flow naturally with consistent padding */
}

.page-header {
  margin-bottom: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Border removed - now handled by .page-header-top-row */
}

.page-header h1 {
  font-size: var(--text-5xl);
  line-height: 1.2;
  color: var(--primary);
  margin-bottom: var(--space-1-5);
  font-weight: 700;
}

/* Editable title */
.page-header h1.editable-title {
  cursor: text;
  padding: 2px 6px;
  margin-left: -6px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.page-header h1.editable-title:hover {
  background-color: var(--background-tertiary);
}

.page-header h1.editable-title:focus {
  outline: none;
  background-color: var(--background-secondary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.page-header h1.editable-title.saving {
  opacity: 0.7;
  pointer-events: none;
}

.page-header p {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.06);
  margin-bottom: var(--space-6);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.1);
}

.card h3 {
  font-size: var(--text-lg);
  line-height: 1.3;
  margin-bottom: var(--space-4);
  color: var(--primary);
  font-weight: 700;
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--bg-light);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

/* File Upload */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.02);
}

.upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.05);
}

.upload-icon {
  font-size: var(--text-7xl);
  margin-bottom: var(--space-4);
  color: var(--text-muted);
}

.upload-zone h4 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
  color: var(--text-header);
}

.upload-zone p {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.file-input {
  display: none;
}

/* Upload Options Layout (Local + Cloud) */
.upload-options {
  display: flex;
  align-items: stretch;
  gap: var(--space-4);
}

.upload-options .upload-zone {
  flex: 1;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-divider {
  display: flex;
  align-items: center;
  padding: 0 var(--space-2);
}

.upload-divider span {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cloud-import-zone {
  flex: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  transition: all 0.2s;
}

.cloud-import-zone:hover {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.02);
}

.cloud-import-icon {
  margin-bottom: var(--space-3);
}

.cloud-import-zone h4 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
  color: var(--text-header);
}

.cloud-import-zone p {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.cloud-import-zone p.cloud-hint {
  margin-bottom: 0;
  margin-top: var(--space-3);
}

/* Provider Icon Buttons */
.cloud-provider-icons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
}

.provider-icons-loading {
  padding: var(--space-4);
}

.spinner-sm {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.provider-icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-3) var(--space-3);
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 72px;
  position: relative;
}

.provider-icon-btn:hover {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.05);
}

.provider-icon-btn.connected::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  border: 2px solid var(--bg-white);
}

.provider-icon-btn.not-connected {
  opacity: 0.6;
}

.provider-icon-btn.not-connected:hover {
  opacity: 1;
  border-color: var(--primary);
}

.provider-icon-btn.coming-soon {
  opacity: 0.4;
  cursor: not-allowed;
}

.provider-icon-btn.coming-soon:hover {
  border-color: var(--border);
  background: var(--bg-white);
}

.provider-icon-btn img {
  width: 28px;
  height: 28px;
}

.provider-icon-btn .provider-icon-emoji {
  font-size: 28px;
  line-height: 1;
}

.provider-icon-btn .provider-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
}

.provider-icon-btn.not-connected .provider-label {
  color: var(--text-muted);
}

.provider-icon-btn .provider-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 9px;
  padding: 2px 4px;
  background: var(--bg-light);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* Responsive: Stack on mobile */
@media (max-width: 768px) {
  .upload-options {
    flex-direction: column;
  }

  .upload-divider {
    padding: var(--space-2) 0;
    justify-content: center;
  }

  .upload-divider span {
    position: relative;
    padding: 0 var(--space-4);
  }

  .upload-divider span::before,
  .upload-divider span::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 60px;
    height: 1px;
    background: var(--border);
  }

  .upload-divider span::before {
    right: 100%;
  }

  .upload-divider span::after {
    left: 100%;
  }
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: var(--space-4);
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}

/* Upload Progress Info */
.upload-progress-info {
  margin-bottom: var(--space-2);
}

.upload-filename {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

/* File List */
.file-list {
  list-style: none;
}

.file-item {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  transition: all 0.2s;
}

.file-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-ultra-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: var(--space-4);
  font-size: var(--text-lg);
}

.file-info {
  flex: 1;
}

.file-name {
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.file-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.file-type-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-light);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.google-icon-file {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.file-actions {
  display: flex;
  gap: var(--space-2);
}

.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  margin-right: var(--space-2);
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.badge-processing {
  background: #dbeafe;
  color: #1e40af;
}

.badge-ready {
  background: #d1fae5;
  color: #065f46;
}

.badge-failed {
  background: #fee2e2;
  color: #991b1b;
}

/* Source badges for cloud files */
.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: 4px;
}

.source-badge.source-cloud {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
}

.source-badge.source-cloud[title*="Google"] {
  background: #fef3c7;
  color: #b45309;
}

.source-badge.source-cloud[title*="Notion"] {
  background: #f3f4f6;
  color: #374151;
}

/* Google Workspace Icons */
.google-icon {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-left: 6px;
}

.google-icon-file {
  width: 22px;
  height: 22px;
  vertical-align: middle;
}

.google-icon-btn {
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

.google-icon-lg {
  width: 24px;
  height: 24px;
  vertical-align: middle;
}

.google-icon-xl {
  width: 32px;
  height: 32px;
  vertical-align: middle;
}

.google-icon-sm {
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

.btn-google-view {
  padding: 4px;
}

.btn-google-view:hover {
  background: var(--background-hover);
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  margin-right: var(--space-2);
}

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

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding: var(--space-4);
    max-width: 100%;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .dashboard {
    flex-direction: column;
  }
}

/* Utilities */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-4); }
.mt-3 { margin-top: var(--space-6); }
.mt-4 { margin-top: var(--space-8); }

.mb-1 { margin-bottom: var(--space-2); }
.mb-2 { margin-bottom: var(--space-4); }
.mb-3 { margin-bottom: var(--space-6); }
.mb-4 { margin-bottom: var(--space-8); }

/* Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.08);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 100%);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.15);
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-card.clickable:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.2);
}

.stat-icon {
  font-size: var(--text-2xl);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-ultra-light);
  border-radius: var(--radius-md);
  color: var(--primary);
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-1);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* File Type Chart - Compact Stacked Bar Design */
.file-type-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 35px; /* Space for tooltips */
}

.file-type-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.file-type-total {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.file-type-stacked-bar {
  display: flex;
  width: 100%;
  height: 20px;
  border-radius: 10px;
  overflow: visible;
  background: var(--light);
  position: relative;
}

.file-type-segment {
  height: 100%;
  min-width: 4px;
  transition: opacity 0.2s;
  cursor: pointer;
  position: relative;
}

.file-type-segment:hover {
  opacity: 0.85;
}

/* Custom tooltip for file type elements */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  z-index: 100;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
}

.file-type-segment:first-child {
  border-radius: 10px 0 0 10px;
}

.file-type-segment:last-child {
  border-radius: 0 10px 10px 0;
}

.file-type-segment:only-child {
  border-radius: 10px;
}

.file-type-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.file-type-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
  cursor: default;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-icon {
  font-size: 14px;
}

.legend-count {
  font-weight: 600;
  color: var(--text-muted);
}

.file-type-source {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.source-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.source-icon {
  font-size: 12px;
}

.source-count {
  font-weight: 600;
}

.source-label {
  opacity: 0.8;
}

.source-divider {
  color: var(--border);
}

/* File Type Metrics - Clean list display */
.file-type-metrics {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.file-type-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.file-type-metric-row:last-child {
  border-bottom: none;
}

.metric-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.metric-icon {
  font-size: 14px;
}

.metric-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.metric-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.metric-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 24px;
  text-align: right;
}

.metric-percent {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

.metric-size {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 55px;
  text-align: right;
}

.chart-loading {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-5);
}

/* Legacy styles kept for backwards compatibility */
.file-type-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
}

.file-type-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-base);
  color: var(--text);
}

.file-type-progress {
  width: 100%;
  height: 24px;
  background: var(--light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.file-type-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width 0.3s;
}

/* Filters Bar */
.filters-bar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.filter-group {
  flex: 1;
  min-width: 200px;
}

/* Bulk Actions */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--light);
  border-radius: var(--radius-sm);
  margin-top: var(--space-4);
}

.bulk-actions span {
  font-weight: 500;
  margin-right: auto;
}

/* Files Table */
.files-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
  table-layout: fixed;
}

.files-table thead {
  background: var(--light);
}

.files-table th {
  padding: var(--space-3);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--dark);
  border-bottom: 2px solid var(--border);
}

/* Fixed column widths for files table */
.files-table th:nth-child(1),
.files-table td:nth-child(1) { width: 40px; } /* Checkbox */
.files-table th:nth-child(2),
.files-table td:nth-child(2) { width: 280px; max-width: 350px; overflow: visible; } /* File name + tab badge - overflow visible for tooltip */
.files-table th:nth-child(3),
.files-table td:nth-child(3) { width: 65px; } /* Type */
.files-table th:nth-child(4),
.files-table td:nth-child(4) { width: 90px; } /* Size */
.files-table th:nth-child(5),
.files-table td:nth-child(5) { width: 90px; } /* Status */
.files-table th:nth-child(6),
.files-table td:nth-child(6) { width: 55px; } /* Quality */
.files-table th:nth-child(7),
.files-table td:nth-child(7) { width: 125px; } /* Uploaded */
.files-table th:nth-child(8),
.files-table td:nth-child(8) { width: 110px; } /* By */
.files-table th:nth-child(9),
.files-table td:nth-child(9) { width: 145px; } /* Actions */

/* Compact action buttons in files table */
.files-table .table-actions {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
}

.files-table .table-actions .btn-icon {
  padding: 4px 6px;
  font-size: 14px;
  min-width: unset;
}

.files-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-table tr:hover {
  background: var(--light);
}

.files-table tr.row-selected {
  background: rgba(37, 99, 235, 0.05);
}

/* Notification highlight animation */
.files-table tr.notification-highlight {
  animation: notification-pulse 3s ease-out;
}

@keyframes notification-pulse {
  0% {
    background: rgba(13, 148, 136, 0.3);
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.5);
  }
  50% {
    background: rgba(13, 148, 136, 0.15);
    box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.3);
  }
  100% {
    background: transparent;
    box-shadow: none;
  }
}

/* Sortable column headers */
.files-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.files-table th.sortable:hover {
  background: var(--border);
}

.files-table th.sortable.active {
  color: var(--primary);
}

.sort-icon {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0;
  transition: opacity 0.15s;
}

.files-table th.sortable:hover .sort-icon {
  opacity: 0.4;
  border-top: 5px solid currentColor;
  border-bottom: none;
}

.files-table th.sortable.active .sort-icon {
  opacity: 1;
}

.sort-icon.asc {
  border-bottom: 5px solid currentColor;
  border-top: none;
}

.sort-icon.desc {
  border-top: 5px solid currentColor;
  border-bottom: none;
}

.file-name-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* Custom tooltip for file names - light highlight like native tooltips */
.file-name-tooltip {
  position: fixed;
  padding: 4px 8px;
  background: #fefcd0;
  color: #1a1a1a;
  border: 1px solid #d4d0a7;
  border-radius: 3px;
  font-size: 12px;
  white-space: nowrap;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 10000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

/* Tab badge for cloud files with multiple tabs/sheets */
.tab-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  background: var(--surface-1);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  margin-left: 4px;
}

.tab-badge.tab-all {
  background: var(--surface-2);
  color: var(--text-1);
}

.table-actions {
  display: flex;
  gap: var(--space-2);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-2xl);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-2xs);
  transition: background 0.2s;
}

.btn-icon:hover {
  background: var(--light);
}

.btn-icon-danger:hover {
  background: #fee2e2;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) 0;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(27, 28, 32, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Keep standard (page-level) modals above custom in-page overlays (e.g. project modals) */
  z-index: calc(var(--z-modal-backdrop) + 10);
  padding: var(--space-5);
  overflow-y: auto;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(27, 28, 32, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  padding: var(--space-5);
  overflow-y: auto;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: var(--z-modal);
}

.modal-small {
  max-width: 400px;
}

.modal-large {
  max-width: 900px;
  max-height: 90vh;
}

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

.modal-header h2,
.modal-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  color: var(--text-header);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--text-2xl);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--light);
  color: var(--text);
}

.modal-body p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Generation Stats (document creation modal) */
.generation-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--background-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.stat-chip strong {
  color: var(--text);
}

/* Streaming Modal Styles */
.streaming-modal-content {
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.streaming-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  min-height: 0;
}

.streaming-status-bar {
  padding: 16px 24px;
  background: var(--background-secondary);
  border-bottom: 1px solid var(--border);
}

.streaming-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.streaming-status-row .spinner-sm {
  flex-shrink: 0;
}

#streaming-status-text {
  flex: 1;
  font-weight: 500;
}

.streaming-char-count {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.streaming-progress-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.streaming-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.3s ease, background 0.3s ease;
}

.streaming-preview {
  padding: 24px;
  font-size: 14px;
  line-height: 1.7;
  min-height: 300px;
  max-height: 50vh;
  overflow-y: auto;
}

.streaming-preview .markdown-content h1 {
  font-size: 1.5em;
  margin-top: 0;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.streaming-preview .markdown-content h2 {
  font-size: 1.25em;
  margin-top: 24px;
  margin-bottom: 12px;
}

.streaming-preview .markdown-content h3 {
  font-size: 1.1em;
  margin-top: 20px;
  margin-bottom: 8px;
}

.streaming-preview .markdown-content p {
  margin-bottom: 12px;
}

.streaming-preview .markdown-content ul,
.streaming-preview .markdown-content ol {
  margin-bottom: 12px;
  padding-left: 24px;
}

.streaming-preview .markdown-content li {
  margin-bottom: 4px;
}

.streaming-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--background);
  flex-shrink: 0;
}

.streaming-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.streaming-actions .btn-primary {
  min-width: 140px;
}

/* Tab Selection Modal (Google Sheets/Docs import) */
.tab-selection-modal {
  max-width: 500px;
}

.tab-selection-modal .modal-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
}

.tab-selection-modal .modal-header-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background-secondary);
  border-radius: 12px;
}

.tab-selection-modal .modal-header-icon svg {
  width: 28px;
  height: 28px;
}

.tab-selection-modal .modal-header-text {
  flex: 1;
  min-width: 0;
}

.tab-selection-modal .modal-header-text h2 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.tab-selection-modal .modal-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-selection-modal .modal-close-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.tab-selection-modal .modal-close-btn:hover {
  background: var(--background-secondary);
  color: var(--text);
}

.tab-selection-modal .modal-body {
  padding: 0 24px 16px;
}

.tab-selection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 16px; /* Align with tab item content padding */
}

.tab-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.select-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.select-all-btn:hover {
  background: var(--background-secondary);
  border-color: var(--text-muted);
  color: var(--text);
}

.tab-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
  margin: 0 -4px;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-item:hover {
  border-color: var(--primary-light);
  background: var(--background-secondary);
}

.tab-item.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.tab-item input[type="checkbox"] {
  display: none;
}

.tab-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  background: var(--white);
}

.tab-checkbox svg {
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.15s;
  stroke: white;
}

.tab-item input:checked ~ .tab-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.tab-item input:checked ~ .tab-checkbox svg {
  opacity: 1;
  transform: scale(1);
}

.tab-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-title {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-selection-modal .modal-footer {
  padding: 16px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.tab-selection-modal .modal-footer .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-selection-modal .modal-footer .btn-secondary {
  background: var(--background);
  border: 1px solid var(--border);
  color: var(--text);
  min-width: 100px;
}

.tab-selection-modal .modal-footer .btn-secondary:hover {
  background: var(--background-secondary);
  border-color: var(--text-muted);
}

.tab-selection-modal .modal-footer .btn-primary {
  background: var(--primary);
  border: none;
  color: white;
  flex: 1;
  max-width: 200px;
}

.tab-selection-modal .modal-footer .btn-primary:hover {
  background: var(--primary-dark);
}

.tab-selection-modal .modal-footer .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Dark mode support for tab selection modal */
html[data-theme="dark"] .tab-selection-modal .modal-header-icon {
  background: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .tab-item {
  background: rgba(255, 255, 255, 0.02);
}

html[data-theme="dark"] .tab-item.selected {
  background: rgba(59, 130, 246, 0.1);
}

html[data-theme="dark"] .tab-checkbox {
  background: var(--background);
}

/* No Context Warning Banner */
.no-context-banner {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.no-context-banner .banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.no-context-banner .banner-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.no-context-banner .banner-text {
  flex: 1;
  font-size: 13px;
  color: #92400e;
}

.no-context-banner .banner-dismiss {
  background: none;
  border: none;
  color: #92400e;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
}

.no-context-banner .banner-dismiss:hover {
  opacity: 1;
}

/* Dark mode support for banner */
html[data-theme="dark"] .no-context-banner {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.3);
}

html[data-theme="dark"] .no-context-banner .banner-text,
html[data-theme="dark"] .no-context-banner .banner-dismiss {
  color: #fcd34d;
}

/* File Details */
.file-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.detail-row {
  display: flex;
  gap: var(--space-3);
}

.detail-label {
  font-weight: 600;
  min-width: 120px;
  color: var(--dark);
}

.detail-value {
  flex: 1;
  color: var(--text);
}

/* Context Items */
.context-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.context-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.context-content {
  padding: var(--space-3);
  background: var(--light);
  border-radius: var(--radius-xs);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: var(--text-base);
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
}

.context-metadata {
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--light);
  border-radius: var(--radius-xs);
  font-size: var(--text-md);
}

.context-metadata pre {
  margin-top: var(--space-2);
  overflow-x: auto;
}

/* Badge Secondary */
.badge-secondary {
  background: var(--light);
  color: var(--dark);
}

/* Permissions Modal */
.permissions-user-info {
  margin-bottom: var(--space-4);
}

.permissions-table-wrapper {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.permissions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
  table-layout: fixed;
}

.permissions-table thead {
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.permissions-table th {
  padding: var(--space-3-5) var(--space-3);
  background: var(--primary);
  border-bottom: 2px solid var(--primary-dark);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-md);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--white);
}

.permissions-table thead {
  background: var(--primary);
}

.permissions-table th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.permissions-table th:last-child {
  border-radius: 0 8px 0 0;
}

.permissions-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.permissions-table tbody tr:last-child td {
  border-bottom: none;
}

.permissions-table tbody tr:hover {
  background: var(--light);
  transition: background 0.2s ease;
}

.permissions-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.permissions-table input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Permissions Table Column Widths - Document permissions modal (Document, Category, View, Edit) */
.permissions-table th:nth-child(1),
.permissions-table td:nth-child(1) { width: 45%; } /* Document */
.permissions-table th:nth-child(2),
.permissions-table td:nth-child(2) { width: 25%; } /* Category */
.permissions-table th:nth-child(3),
.permissions-table td:nth-child(3) { width: 15%; text-align: center; } /* View */
.permissions-table th:nth-child(4),
.permissions-table td:nth-child(4) { width: 15%; text-align: center; } /* Edit */

/* Role Permissions Matrix - (Permission, Master, Admin, Editor, Viewer) */
.permissions-matrix {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.permissions-matrix th:nth-child(1),
.permissions-matrix td:nth-child(1) { width: 40%; text-align: left; } /* Permission name */
.permissions-matrix th:nth-child(2),
.permissions-matrix td:nth-child(2) { width: 15%; text-align: center; } /* Master */
.permissions-matrix th:nth-child(3),
.permissions-matrix td:nth-child(3) { width: 15%; text-align: center; } /* Admin */
.permissions-matrix th:nth-child(4),
.permissions-matrix td:nth-child(4) { width: 15%; text-align: center; } /* Editor */
.permissions-matrix th:nth-child(5),
.permissions-matrix td:nth-child(5) { width: 15%; text-align: center; } /* Viewer */

.permissions-matrix th {
  padding: var(--space-3);
  background: var(--primary);
  color: var(--white);
  font-weight: 600;
  font-size: var(--text-sm);
  text-transform: uppercase;
}

.permissions-matrix th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.permissions-matrix th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

.permissions-matrix td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.permissions-matrix tbody tr:hover {
  background: var(--light);
}

.permissions-matrix .check {
  color: var(--success);
  font-weight: bold;
}

.permissions-matrix .cross {
  color: var(--text-muted);
}

/* Users Table Styling */
.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-4);
  table-layout: fixed;
}

.users-table thead {
  background: var(--primary);
}

.users-table th {
  padding: var(--space-3-5) var(--space-3);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
}

.users-table th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.users-table th:last-child {
  border-radius: 0 8px 0 0;
}

.users-table td {
  padding: var(--space-3-5) var(--space-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
  vertical-align: middle;
}

.users-table tr:hover {
  background: var(--light);
  transition: background 0.2s ease;
}

.users-table tr:last-child td {
  border-bottom: none;
}

/* Users Table Column Widths - 9 columns (users.html: User, Role, Team, Status, Files, Tokens, Last Login, Created, Actions) */
.users-table th:nth-child(1),
.users-table td:nth-child(1) { width: 200px; } /* User */
.users-table th:nth-child(2),
.users-table td:nth-child(2) { width: 80px; } /* Role */
.users-table th:nth-child(3),
.users-table td:nth-child(3) { width: 120px; } /* Team */
.users-table th:nth-child(4),
.users-table td:nth-child(4) { width: 80px; } /* Status */
.users-table th:nth-child(5),
.users-table td:nth-child(5) { width: 60px; text-align: center; } /* Files */
.users-table th:nth-child(6),
.users-table td:nth-child(6) { width: 100px; text-align: right; } /* Tokens Used */
.users-table th:nth-child(7),
.users-table td:nth-child(7) { width: 120px; } /* Last Login */
.users-table th:nth-child(8),
.users-table td:nth-child(8) { width: 120px; } /* Created */
.users-table th:nth-child(9),
.users-table td:nth-child(9) { width: 100px; } /* Actions */

/* Team Settings Page - 8 columns (User, Role, Status, Files, Tokens, Last Login, Joined, Actions) - no Team column */
.team-settings-page .users-table th:nth-child(1),
.team-settings-page .users-table td:nth-child(1) { width: 220px; } /* User */
.team-settings-page .users-table th:nth-child(2),
.team-settings-page .users-table td:nth-child(2) { width: 80px; } /* Role */
.team-settings-page .users-table th:nth-child(3),
.team-settings-page .users-table td:nth-child(3) { width: 80px; } /* Status */
.team-settings-page .users-table th:nth-child(4),
.team-settings-page .users-table td:nth-child(4) { width: 60px; text-align: center; } /* Files */
.team-settings-page .users-table th:nth-child(5),
.team-settings-page .users-table td:nth-child(5) { width: 100px; text-align: right; } /* Tokens Used */
.team-settings-page .users-table th:nth-child(6),
.team-settings-page .users-table td:nth-child(6) { width: 120px; } /* Last Login */
.team-settings-page .users-table th:nth-child(7),
.team-settings-page .users-table td:nth-child(7) { width: 120px; } /* Joined */
.team-settings-page .users-table th:nth-child(8),
.team-settings-page .users-table td:nth-child(8) { width: 100px; } /* Actions */

/* User Cell */
.user-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--white);
  font-size: var(--text-xl);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb, 109, 38, 171), 0.3);
}

.user-name-cell {
  font-weight: 600;
  color: var(--dark);
  margin-bottom: var(--space-0-5);
}

.user-email-cell {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Role and Status Badges */
.role-badge, .status-badge {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-block;
}

/* Generating status badge with pulse animation */
.status-badge.generating {
  background: #f59e0b;
  color: white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.role-master {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb, 109, 38, 171), 0.3);
}

.role-admin {
  background: var(--primary-light);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(var(--primary-light-rgb, 134, 66, 196), 0.3);
}

.role-editor {
  background: var(--success);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.role-viewer {
  background: var(--warning);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.status-active {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.status-inactive {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Stat Numbers */
.stat-number {
  font-weight: 600;
  color: var(--dark);
  padding: var(--space-1) var(--space-2);
  background: var(--light);
  border-radius: var(--radius-xs);
  display: inline-block;
  min-width: 40px;
  text-align: center;
}

.token-count {
  background: var(--light);
  color: var(--primary);
  font-weight: 700;
  border: 1px solid var(--border);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: var(--space-1-5);
  align-items: center;
}

.action-buttons .btn-icon {
  background: var(--light);
  border-radius: var(--radius-xs);
  padding: var(--space-1-5) var(--space-2-5);
  transition: all 0.2s;
}

.action-buttons .btn-icon:hover {
  background: var(--primary);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb, 109, 38, 171), 0.3);
}

/* Inactive User Row */
.user-row.inactive-user {
  opacity: 0.6;
}

.user-row.inactive-user td {
  color: var(--text-muted);
}

/* Enhanced Card Styling for Team Members */
.card h3 {
  color: var(--primary);
  font-size: var(--text-3xl);
  font-weight: 700;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 3px solid var(--light);
}

/* Filters Section Enhancement */
.filters-row {
  display: flex;
  gap: var(--space-4);
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 200px;
}

.filter-group label {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: var(--text-sm);
}

/* Compact table filters */
.table-filters-compact {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.form-control-compact {
  padding: var(--space-1-5) var(--space-2-5);
  font-size: var(--text-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  transition: all 0.2s ease;
  font-family: inherit;
  background: var(--white);
  height: 32px;
  box-sizing: border-box;
}

.form-control-compact:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.form-control-compact:hover {
  border-color: var(--primary-light);
}

/* Responsive: stack filters on smaller screens */
@media (max-width: 768px) {
  .table-filters-compact {
    flex-wrap: wrap;
    margin-top: var(--space-2);
  }

  .table-filters-compact .form-control-compact {
    width: 100% !important;
    min-width: 120px;
  }

  .card > div:first-child {
    flex-direction: column;
    align-items: flex-start !important;
  }
}

/* Recently Deleted link - subtle text link in filters */
.deleted-files-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.deleted-files-link:hover {
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.08);
  text-decoration: none;
}

/* =============================================================================
   DARK THEME SUPPORT
   ============================================================================= */

[data-theme="dark"],
html[data-theme="dark"] {
  /* Override CSS variables for dark theme */
  --light: #1e293b;
  --white: #334155;
  --text: #f1f5f9;
  --text-muted: #cbd5e1;
  --border: #475569;
  --dark: #f1f5f9;
  --dark-light: #cbd5e1;
  --bg-muted: #1e293b;
  --secondary: #94a3b8;

  /* Keep alias variables consistent in dark mode */
  --bg-primary: var(--white);
  --bg-secondary: #1e293b;
  --border-color: var(--border);
  --text-primary: var(--text);
  --text-secondary: var(--text-muted);
}

/* Body and main layout */
[data-theme="dark"] body,
html[data-theme="dark"] body {
  background: #0f172a;
  color: var(--text);
}

[data-theme="dark"] .main-content,
html[data-theme="dark"] .main-content {
  background: #0f172a;
}

/* Sidebar - keep it dark but adjust borders */
[data-theme="dark"] .sidebar,
html[data-theme="dark"] .sidebar {
  background: #1e293b;
  border-right: 1px solid var(--border);
}

[data-theme="dark"] .sidebar-header,
html[data-theme="dark"] .sidebar-header {
  border-bottom-color: var(--border);
}

[data-theme="dark"] .sidebar-footer,
html[data-theme="dark"] .sidebar-footer {
  border-top-color: var(--border);
}

/* Cards */
[data-theme="dark"] .card,
html[data-theme="dark"] .card {
  background: var(--white);
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .card:hover,
html[data-theme="dark"] .card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .card h3,
html[data-theme="dark"] .card h3 {
  color: var(--text);
  border-bottom-color: var(--border);
}

/* Page header */
[data-theme="dark"] .page-header,
html[data-theme="dark"] .page-header {
  border-bottom-color: var(--border);
  background: #0f172a;
}

[data-theme="dark"] .page-header h1,
html[data-theme="dark"] .page-header h1 {
  color: var(--primary-light);
}

[data-theme="dark"] .page-header p,
html[data-theme="dark"] .page-header p {
  color: var(--text-muted);
}

/* Form controls */
[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-control {
  background: #1e293b;
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-control:focus {
  background: #1e293b;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 109, 38, 171), 0.2);
}

[data-theme="dark"] .form-control:hover:not(:disabled),
html[data-theme="dark"] .form-control:hover:not(:disabled) {
  border-color: var(--primary-light);
}

[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control:disabled {
  background: #0f172a;
  opacity: 0.5;
}

/* Buttons */
[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-secondary {
  background: #1e293b;
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-secondary:hover {
  background: #0f172a;
  border-color: var(--primary-light);
}

/* Alerts */
[data-theme="dark"] .alert-error,
html[data-theme="dark"] .alert-error {
  background: #7f1d1d;
  color: #fecaca;
  border-color: #991b1b;
}

[data-theme="dark"] .alert-success,
html[data-theme="dark"] .alert-success {
  background: #064e3b;
  color: #a7f3d0;
  border-color: #065f46;
}

[data-theme="dark"] .alert-info,
html[data-theme="dark"] .alert-info {
  background: #1e3a8a;
  color: #bfdbfe;
  border-color: #1e40af;
}

/* Badges */
[data-theme="dark"] .badge-pending,
html[data-theme="dark"] .badge-pending {
  background: #78350f;
  color: #fde68a;
}

[data-theme="dark"] .badge-processing,
html[data-theme="dark"] .badge-processing {
  background: #1e3a8a;
  color: #93c5fd;
}

[data-theme="dark"] .badge-ready,
html[data-theme="dark"] .badge-ready {
  background: #064e3b;
  color: #6ee7b7;
}

[data-theme="dark"] .badge-failed,
html[data-theme="dark"] .badge-failed {
  background: #7f1d1d;
  color: #fca5a5;
}

/* File items */
[data-theme="dark"] .file-item,
html[data-theme="dark"] .file-item {
  background: var(--white);
  border-color: var(--border);
}

[data-theme="dark"] .file-item:hover,
html[data-theme="dark"] .file-item:hover {
  background: #1e293b;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .file-icon,
html[data-theme="dark"] .file-icon {
  background: #1e293b;
}

/* Upload zone */
[data-theme="dark"] .upload-zone,
html[data-theme="dark"] .upload-zone {
  border-color: var(--border);
  background: #1e293b;
}

[data-theme="dark"] .upload-zone:hover,
html[data-theme="dark"] .upload-zone:hover {
  background: #0f172a;
  border-color: var(--primary-light);
}

[data-theme="dark"] .upload-zone.drag-over,
html[data-theme="dark"] .upload-zone.drag-over {
  background: #1e293b;
  border-color: var(--primary-light);
}

/* Recycle Bin Table */
.recycle-bin-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.recycle-bin-table th,
.recycle-bin-table td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recycle-bin-table thead {
  background: var(--light);
}

.recycle-bin-table th {
  font-weight: 600;
  color: var(--dark);
}

.recycle-bin-table tr:hover {
  background: var(--light);
}

/* Recycle Bin Table Column Widths - (Name, Type, Deleted Date, Deleted By, Actions) */
.recycle-bin-table th:nth-child(1),
.recycle-bin-table td:nth-child(1) { width: 35%; } /* Name */
.recycle-bin-table th:nth-child(2),
.recycle-bin-table td:nth-child(2) { width: 15%; } /* Type */
.recycle-bin-table th:nth-child(3),
.recycle-bin-table td:nth-child(3) { width: 20%; } /* Deleted Date */
.recycle-bin-table th:nth-child(4),
.recycle-bin-table td:nth-child(4) { width: 15%; } /* Deleted By */
.recycle-bin-table th:nth-child(5),
.recycle-bin-table td:nth-child(5) { width: 15%; } /* Actions */

/* Data Table (Platform Admin) - auto layout for flexible column widths */
.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table thead {
  background: var(--light);
}

.data-table th {
  font-weight: 600;
  color: var(--dark);
}

.data-table tr:hover {
  background: var(--light);
}

/* Tables - Dark Theme */
[data-theme="dark"] table,
html[data-theme="dark"] table {
  color: var(--text);
}

[data-theme="dark"] th,
html[data-theme="dark"] th {
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] td,
html[data-theme="dark"] td {
  border-color: var(--border);
}

/* Text colors */
[data-theme="dark"] .text-muted,
html[data-theme="dark"] .text-muted {
  color: var(--text-muted) !important;
}

/* Login page */
[data-theme="dark"] .login-box,
html[data-theme="dark"] .login-box {
  background: #1e293b;
  color: var(--text);
}

[data-theme="dark"] .login-header h1,
html[data-theme="dark"] .login-header h1 {
  color: var(--text);
}

[data-theme="dark"] .login-header p,
html[data-theme="dark"] .login-header p {
  color: var(--text-muted);
}

/* ==================== FILE PROCESSING PROGRESS ==================== */

.file-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
  width: 100%;
  max-width: 140px;
}

.progress-bar-container {
  width: 100%;
  height: 12px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-xs);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.file-progress .progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%);
  transition: width 0.3s ease;
  border-radius: var(--radius-2xs);
  position: relative;
  overflow: hidden;
}

/* Animated shine effect */
.file-progress .progress-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shine 2s ease-in-out infinite;
}

@keyframes shine {
  0% { left: -100%; }
  100% { left: 100%; }
}

.progress-message {
  font-size: var(--text-sm);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

/* ==================== END FILE PROCESSING PROGRESS ==================== */

/* Settings Page Styles */
.settings-section {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.settings-section h4 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-header);
  margin-bottom: var(--space-2);
}

.setting-description {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.model-selector-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-5);
}

@media (max-width: 768px) {
  .model-selector-group {
    grid-template-columns: 1fr;
  }
}

.model-info {
  min-height: 60px;
}

.form-hint {
  display: block;
  font-size: var(--text-md);
  color: var(--text-muted);
  margin-top: var(--space-1-5);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  font-size: var(--text-lg);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.checkbox-label span {
  font-weight: 500;
}

/* ==================== TEAM & PLATFORM ADMIN STYLES ==================== */

/* Platform Admin Badge */
.badge {
  display: inline-block;
  padding: var(--space-0-5) var(--space-2);
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius-md);
  margin-left: var(--space-2);
  vertical-align: middle;
}

.badge-platform-admin {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}

.badge-team-owner {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

/* Team Name in Sidebar Header - DEPRECATED (now using .team-context section above) */
/* Commenting out to prevent conflicts with new team-selector layout */
/*
.sidebar-header .team-info {
  margin-top: var(--space-3-5);
  padding-top: var(--space-3-5);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header .team-name {
  font-size: var(--text-md);
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  padding: var(--space-1-5) var(--space-3);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-3xl);
}
*/

/* Removed: icon now shown in team-avatar instead */
/* .sidebar-header .team-name::before {
  content: '🏢';
  font-size: var(--text-sm);
} */

/* Team Branding (Logo or Default Icon) */
.team-branding {
  margin-bottom: var(--space-4);
  display: flex;
  justify-content: center;
}

.team-logo {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-xl);
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.team-default-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-5xl);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-xl);
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Platform Admin Navigation Links - No special separator needed with new nav-item margins */
.nav-item.platform-admin-only {
  /* Inherits standard nav-item styles */
}

/* Platform Admin Active State - Orange/Amber Styling */
.nav-item.platform-admin-only.active {
  background: rgba(245, 158, 11, 0.15);
  border-left-color: #f59e0b;
  color: rgba(255, 255, 255, 1);
}

.nav-item.platform-admin-only:hover {
  background: rgba(245, 158, 11, 0.1);
  border-left-color: rgba(245, 158, 11, 0.5);
}

.nav-item.platform-admin-only.active:hover {
  background: rgba(245, 158, 11, 0.2);
}

/* User Info Section Enhancement */
.user-info .user-details p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

/* Team Context Banner (optional - for pages that need prominent display) */
.team-context-banner {
  background: var(--primary-lighter);
  border-left: 4px solid var(--primary);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  border-radius: 0 8px 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.team-context-banner .team-label {
  font-size: var(--text-md);
  color: var(--text-muted);
}

.team-context-banner .team-value {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

/* Platform Admin View Indicator */
.platform-admin-indicator {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  color: #92400e;
}

.platform-admin-indicator::before {
  content: '👑';
  font-size: var(--text-xl);
}

/* ==================== END TEAM & PLATFORM ADMIN STYLES ==================== */

/* ==================== FILE TAGGING & TOPICS STYLES ==================== */

/* Tags container in file details */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-2) 0;
  min-height: 32px;
}

.tags-container:empty::before {
  content: 'No topics assigned';
  color: #999;
  font-size: var(--text-md);
  align-self: center;
  font-style: italic;
}

/* Individual tag badge */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border: 1px solid #2196f3;
  border-radius: var(--radius-2xl);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-md);
  color: #1565c0;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.tag-badge:hover {
  background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

/* Remove tag button */
.tag-remove-btn {
  background: none;
  border: none;
  color: #1565c0;
  cursor: pointer;
  font-size: var(--text-xl);
  padding: 0;
  margin: 0;
  line-height: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

/* Confidence-based tag colors (blue with opacity intensity) */
/* Same blue color (#2196f3) with different opacity levels for intensity */

.tag-badge.tag-confidence-high {
  background: rgba(33, 150, 243, 1);
  border: 1px solid rgba(33, 150, 243, 1);
  color: #ffffff;
}

.tag-badge.tag-confidence-high:hover {
  background: rgba(13, 71, 161, 0.95);
  border-color: rgba(13, 71, 161, 0.95);
  box-shadow: 0 3px 8px rgba(33, 150, 243, 0.4);
}

.tag-badge.tag-confidence-medium {
  background: rgba(33, 150, 243, 0.85);
  border: 1px solid rgba(33, 150, 243, 0.85);
  color: #ffffff;
}

.tag-badge.tag-confidence-medium:hover {
  background: rgba(33, 150, 243, 0.95);
  border-color: rgba(33, 150, 243, 0.95);
  box-shadow: 0 3px 8px rgba(33, 150, 243, 0.4);
}

.tag-badge.tag-confidence-low {
  background: rgba(33, 150, 243, 0.65);
  border: 1px solid rgba(33, 150, 243, 0.65);
  color: #ffffff;
}

.tag-badge.tag-confidence-low:hover {
  background: rgba(33, 150, 243, 0.80);
  border-color: rgba(33, 150, 243, 0.80);
  box-shadow: 0 2px 6px rgba(33, 150, 243, 0.3);
}

.tag-badge.tag-confidence-very-low {
  background: rgba(33, 150, 243, 0.40);
  border: 1px solid rgba(33, 150, 243, 0.40);
  color: rgba(33, 150, 243, 1);
}

.tag-badge.tag-confidence-very-low:hover {
  background: rgba(33, 150, 243, 0.60);
  border-color: rgba(33, 150, 243, 0.60);
  box-shadow: 0 2px 5px rgba(33, 150, 243, 0.3);
}

/* User-added tags (distinct from AI tags) */
.tag-badge.tag-user-added {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border: 1px solid #66bb6a;
  color: #2e7d32;
}

.tag-badge.tag-user-added:hover {
  background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
  box-shadow: 0 2px 6px rgba(102, 187, 106, 0.3);
}

/* Confidence score badge inside tag */
.tag-confidence-badge {
  display: inline-block;
  font-size: var(--text-2xs);
  font-weight: 600;
  margin-left: var(--space-1);
  padding: var(--space-px) var(--space-1);
  border-radius: var(--radius-2xs);
  background: rgba(255, 255, 255, 0.3);
}

/* See All button styling */
.btn-see-all-tags {
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
  border: 1px solid #bdbdbd;
  border-radius: var(--radius-xs);
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-md);
  font-weight: 500;
  color: #424242;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: var(--space-2);
}

.btn-see-all-tags:hover {
  background: linear-gradient(135deg, #e0e0e0 0%, #bdbdbd 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

/* Tag actions row adjustment */
.tag-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.tag-remove-btn:hover {
  background-color: rgba(211, 47, 47, 0.1);
  color: #d32f2f;
}

/* Tag actions (buttons) */
.tag-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.btn-tag-action {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-sm);
  border: 1px solid #ddd;
  background: white;
  color: #666;
  border-radius: var(--radius-2xs);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-tag-action:hover {
  border-color: #2196f3;
  color: #2196f3;
  background-color: #f5f5f5;
}

.btn-tag-action.primary {
  background: #2196f3;
  color: white;
  border-color: #2196f3;
}

.btn-tag-action.primary:hover {
  background: #1976d2;
  border-color: #1976d2;
}

/* Generate/Regenerate tags button */
.btn-tag-action.btn-generate-tags {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: white;
  border-color: #7c3aed;
  font-weight: 500;
}

.btn-tag-action.btn-generate-tags:hover {
  background: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%);
  border-color: #6d28d9;
}

.btn-tag-action.btn-regenerate-tags {
  background: #f5f3ff;
  color: #7c3aed;
  border-color: #c4b5fd;
}

.btn-tag-action.btn-regenerate-tags:hover {
  background: #ede9fe;
  border-color: #a78bfa;
}

.btn-tag-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Small spinner for buttons */
.spinner-small {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

/* Tag edit modal content */
.tag-edit-container {
  padding: var(--space-4);
}

.tag-edit-container h4 {
  margin: 0 0 12px 0;
  font-size: var(--text-xl);
  font-weight: 600;
  color: #333;
}

/* Tag checkboxes grid */
.tag-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
  margin: var(--space-4) 0;
  max-height: 400px;
  overflow-y: auto;
  padding: var(--space-2);
  border: 1px solid #eee;
  border-radius: var(--radius-2xs);
  background-color: #fafafa;
}

/* Individual checkbox */
.tag-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-2xs);
  transition: all 0.2s ease;
  user-select: none;
}

.tag-checkbox:hover {
  background-color: #f0f0f0;
}

.tag-checkbox input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: #2196f3;
}

.tag-checkbox span {
  flex: 1;
  font-size: var(--text-md);
  color: #333;
}

.tag-checkbox small {
  color: #999;
  font-size: var(--text-xs);
  margin-left: auto;
  font-style: italic;
}

/* Modal actions for tag editing */
.tag-modal-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid #eee;
}

/* Add new tag input form */
.add-tag-form {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.add-tag-form input {
  flex: 1;
  padding: var(--space-1-5) var(--space-2);
  border: 1px solid #ddd;
  border-radius: var(--radius-2xs);
  font-size: var(--text-sm);
}

.add-tag-form input:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.add-tag-form button {
  padding: var(--space-1-5) var(--space-3);
  background: #2196f3;
  color: white;
  border: none;
  border-radius: var(--radius-2xs);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background 0.2s ease;
}

.add-tag-form button:hover {
  background: #1976d2;
}

/* Tags section in detail row */
.detail-row.tags-row {
  flex-direction: column;
  align-items: flex-start;
}

.detail-row.tags-row strong {
  margin-bottom: var(--space-2);
}

/* ==================== END FILE TAGGING STYLES ==================== */

/* ==================== ADD FILE DROPDOWN ==================== */
.add-file-dropdown {
  position: relative;
}

/* Compact version for inline placement */
.add-file-dropdown.add-file-compact .btn {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
}

.add-file-dropdown.add-file-compact .add-file-menu {
  left: 0;
  right: auto;
}

.add-file-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-width: 260px;
  z-index: 100;
  overflow: hidden;
}

.add-file-dropdown.open .add-file-menu {
  display: block;
}

.add-file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.add-file-item:hover {
  background: var(--bg-secondary, #f5f5f5);
}

.add-file-item:first-child {
  border-bottom: 1px solid var(--border, #eee);
}

.add-file-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.add-file-label {
  font-weight: 500;
  color: var(--text, #1a1a1a);
  font-size: 14px;
}

.add-file-desc {
  font-size: 12px;
  color: var(--text-muted, #666);
  margin-top: 2px;
}
/* ==================== END ADD FILE DROPDOWN ==================== */

/* ==================== INLINE FILE PREVIEW ==================== */

/* Expand button in file row */
.expand-preview-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: all 0.2s ease;
  color: var(--text-muted);
}

.expand-preview-btn:hover {
  background: var(--bg-light);
  color: var(--primary);
}

.expand-preview-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.expand-preview-btn.expanded svg {
  transform: rotate(90deg);
}

/* Preview row */
.preview-row {
  background: var(--bg-ultra-light) !important;
}

.preview-row:hover {
  background: var(--bg-ultra-light) !important;
}

.preview-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--border);
}

/* Preview content container */
.file-preview-container {
  padding: 16px 24px;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 500px;
  }
}

.file-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.file-preview-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.file-preview-actions {
  display: flex;
  gap: 8px;
}

.file-preview-actions .btn {
  font-size: var(--text-sm);
  padding: 4px 10px;
}

/* Preview content text */
.file-preview-content {
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-body);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 200px;
  overflow-y: auto;
  padding: 12px 16px;
  background: var(--white);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.file-preview-content::-webkit-scrollbar {
  width: 6px;
}

.file-preview-content::-webkit-scrollbar-track {
  background: var(--bg-light);
  border-radius: 3px;
}

.file-preview-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.file-preview-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Loading state */
.file-preview-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Empty state */
.file-preview-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-style: italic;
}

/* Error state */
.file-preview-error {
  text-align: center;
  padding: 16px;
  color: var(--danger);
  font-size: var(--text-sm);
  background: rgba(239, 68, 68, 0.05);
  border-radius: var(--radius-sm);
}

/* Preview metadata */
.file-preview-meta {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.file-preview-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.file-preview-meta-label {
  font-weight: 500;
}

/* Truncation indicator */
.file-preview-truncated {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
  margin-top: 8px;
  text-align: right;
}

/* Responsive: Hide expand button on desktop, show on mobile */
.expand-preview-btn {
  display: none; /* Hidden by default (desktop) */
}

@media (max-width: 768px) {
  /* Show expand button on mobile */
  .expand-preview-btn {
    display: flex;
  }

  /* Hide the 📄 View Context button on mobile */
  .btn-view-context {
    display: none !important;
  }
}

/* ==================== END INLINE FILE PREVIEW ==================== */
