/* ========================================
   DESIGN TOKENS - Lityx AI
   Single Source of Truth for Design System

   All pages must import this file BEFORE
   their page-specific CSS to inherit the
   canonical design variables.

   Aesthetic: Deep Space / Monochrome / Silver
   ======================================== */


:root {
  /* ========================================
     COLOR SYSTEM - Default (Dark + Vibrant-ish base)
     ======================================== */
  --primary: #ffffff;
  --primary-glow: #e5e5e5;
  --primary-dark: #a3a3a3;

  /* Status Colors - Default Vibrant */
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* Accent for Form Elements */
  --accent-color: #e5e5e5;

  /* ========================================
     SURFACE COLORS - Deep Space Backgrounds
     ======================================== */
  --surface-0: #020202;
  --surface-1: #0a0a0c;
  --surface-2: #131316;
  --surface-3: #1c1c21;

  /* Sidebar Background - Slightly lighter than surface-0 */
  --sidebar-bg: #0a0a0c;

  /* ========================================
     TEXT COLORS
     ======================================== */
  --text-primary: #ffffff;
  --text-secondary: #bababa;
  --text-muted: #8a8f98;

  /* ========================================
     BORDERS
     ======================================== */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.3);
  --border-default: rgba(255, 255, 255, 0.12);

  /* ========================================
     GRADIENTS
     ======================================== */
  --gradient-primary: linear-gradient(135deg, #ffffff 0%, #737373 100%);
  --gradient-hover: linear-gradient(135deg, #e5e5e5 0%, #525252 100%);

  /* ========================================
     SHADOWS & GLOWS
     ======================================== */
  --glow-primary: 0 0 40px -10px rgba(255, 255, 255, 0.3);
  --shadow-card: 0 0 0 1px var(--border-subtle), 0 8px 30px rgba(0, 0, 0, 0.5);

  /* ========================================
     TYPOGRAPHY
     ======================================== */
  --font-family: "Plus Jakarta Sans", "Google Sans", system-ui, sans-serif;

  /* ========================================
     SPACING
     ======================================== */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* ========================================
     BORDER RADIUS
     ======================================== */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* ========================================
     DASHBOARD GRID
     ======================================== */
  --dashboard-row-height: 200px;
}

/* ========================================
   THEME: DARK (Explicit)
   Matches :root defaults but ensures specificity
   ======================================== */
[data-theme="dark"] {
  --primary: #ffffff;
  --primary-glow: #e5e5e5;
  --primary-dark: #a3a3a3;
  --surface-0: #020202;
  --surface-1: #0a0a0c;
  --surface-2: #131316;
  --surface-3: #1c1c21;
  --sidebar-bg: #0a0a0c;
  --text-primary: #ffffff;
  --text-secondary: #bababa;
  --text-muted: #8a8f98;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.3);
  --border-default: rgba(255, 255, 255, 0.12);
  --gradient-primary: linear-gradient(135deg, #ffffff 0%, #737373 100%);
  --gradient-hover: linear-gradient(135deg, #e5e5e5 0%, #525252 100%);
  --glow-primary: 0 0 40px -10px rgba(255, 255, 255, 0.3);
  --shadow-card: 0 0 0 1px var(--border-subtle), 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ========================================
   THEME: LIGHT
   Applied via [data-theme="light"]
   ======================================== */
[data-theme="light"] {
  --primary: #1a1a1a;
  --primary-glow: #374151;
  --primary-dark: #6b7280;

  --surface-0: #ffffff;
  --surface-1: #f8f9fa;
  --surface-2: #f1f3f5;
  --surface-3: #e9ecef;

  /* Sidebar Background - Light theme */
  --sidebar-bg: #f8f9fa;

  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-muted: #6b7280;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-highlight: rgba(0, 0, 0, 0.2);
  --border-default: rgba(0, 0, 0, 0.1);

  --gradient-primary: linear-gradient(135deg, #374151 0%, #6b7280 100%);
  --gradient-hover: linear-gradient(135deg, #4b5563 0%, #9ca3af 100%);

  --glow-primary: 0 0 40px -10px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ========================================
   STYLE: VIBRANT
   Default semantic colors
   ======================================== */
[data-style="vibrant"] {
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #3b82f6;
}

/* ========================================
   STYLE: MONO (Minimalist)
   Pure greyscale - only white, greys, black
   ======================================== */
[data-style="mono"] {
  /* All semantic colors become grey tones.
     Rely on icons, labels, and context for meaning. */

  /* Dark Mode Mono - Light greys on dark */
  --danger: #888888;
  --success: #909090;
  --warning: #909090;
  --info: #808080;

  /* Remove any accent colors */
  --accent-color: var(--text-muted);
}

[data-theme="light"][data-style="mono"] {
  /* Light Mode Mono - Dark greys on light */
  --danger: #555555;
  --success: #4a4a4a;
  --warning: #4a4a4a;
  --info: #606060;

  --accent-color: var(--text-muted);
}

/* ========================================
   GLOBAL BUTTON SYSTEM - Flat Style
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Primary - Solid color, NO gradient */
.btn-primary {
  background: var(--primary);
  color: var(--surface-0);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* Secondary - Subtle background */
.btn-secondary {
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

/* Ghost - Transparent */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

/* Danger */
.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Danger Filled */
.btn-danger-filled {
  background: var(--danger);
  color: white;
}

.btn-danger-filled:hover {
  opacity: 0.9;
}

/* Small variant */
.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.btn-sm svg {
  width: 16px;
  height: 16px;
}

/* ========================================
   GLOBAL SIDEBAR TOGGLE SYSTEM
   Push layout - sidebar pushes content
   ======================================== */

/* Toggle Button - Top Left */
.sidebar-toggle-btn {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 90;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
  background: var(--surface-2);
}

/* Material Symbols icon */
.sidebar-toggle-btn .material-symbols-outlined {
  font-size: 20px;
  color: var(--text-secondary);
}

/* Toggle button icons - show/hide based on sidebar state */
.sidebar-toggle-btn .icon-close {
  display: none;
}

body.sidebar-open .sidebar-toggle-btn .icon-open {
  display: none;
}

body.sidebar-open .sidebar-toggle-btn .icon-close {
  display: block;
}

.sidebar-toggle-btn svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

/* Hide toggle button when sidebar is open */
body.sidebar-open .sidebar-toggle-btn {
  display: none;
}

/* Disable transitions on initial page load */
body.sidebar-no-transition .sidebar-toggle-btn,
body.sidebar-no-transition .app-sidebar,
body.sidebar-no-transition .sidebar-overlay,
body.sidebar-no-transition .main-content,
body.sidebar-no-transition .container,
body.sidebar-no-transition .chat-main {
  transition: none !important;
}

/* Sidebar Overlay - Mobile only */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.3s ease;
}

/* App Sidebar - Push layout */
.app-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

/* Sidebar opens when body has sidebar-open class */
body.sidebar-open .app-sidebar {
  transform: translateX(0);
}

/* Main content push behavior */
.main-content,
.container,
.chat-main {
  transition: margin-left 0.3s ease, padding-left 0.3s ease;
}

body.sidebar-open .main-content,
body.sidebar-open .container {
  margin-left: 240px;
}

body.sidebar-open .chat-main {
  padding-left: 240px;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  min-height: 64px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.sidebar-brand-logo {
  height: 32px;
  width: auto;
  fill: var(--primary);
}

/* Sidebar Close Button */
.sidebar-close-btn {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
  background: var(--surface-2);
}

.sidebar-close-btn svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.sidebar-close-btn .material-symbols-outlined {
  font-size: 20px;
  color: var(--text-secondary);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 1rem 1.5rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--surface-2);
  color: var(--primary-glow);
}

.sidebar-link.active svg {
  color: var(--primary-glow);
  stroke: var(--primary-glow);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1rem 1.5rem 1rem 0.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-logout-link {
  color: var(--danger);
}

.sidebar-logout-link:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* ========================================
   SIDEBAR PROFILE SUBMENU
   ======================================== */

.sidebar-profile-menu {
  position: relative;
}

/* Botão trigger - herda estilo de .sidebar-link */
.sidebar-profile-trigger {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.sidebar-profile-trigger svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-profile-trigger .sidebar-profile-icon {
  width: 40px;
  height: 40px;
}

.sidebar-profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* Container para avatar + detalhes */
.sidebar-profile-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.sidebar-profile-details {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.sidebar-profile-name {
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Texto de plano Free/Pro - estilo minimalista */
.sidebar-plan-badge {
  font-family: var(--font-family);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.sidebar-profile-trigger .sidebar-link-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-profile-trigger:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

/* Ícone chevron à direita */
.profile-chevron {
  margin-left: auto;
  transition: transform 0.2s ease;
}

.sidebar-profile-menu.open .profile-chevron {
  transform: rotate(180deg);
}

/* Submenu - animação slide suave */
.sidebar-profile-submenu {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  /* Fecho: opacidade primeiro, depois altura e margin juntos */
  transition: opacity 0.15s cubic-bezier(0.4, 0, 1, 1),
              max-height 0.25s cubic-bezier(0.4, 0, 1, 1) 0.1s,
              margin-bottom 0.25s cubic-bezier(0.4, 0, 1, 1) 0.1s;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-profile-menu.open .sidebar-profile-submenu {
  max-height: 200px;
  opacity: 1;
  margin-bottom: 0.5rem;
  overflow: visible; /* Allow fly-out to be visible */
  /* Abertura: altura e margin primeiro, depois opacidade */
  transition: max-height 0.3s cubic-bezier(0, 0, 0.2, 1),
              margin-bottom 0.3s cubic-bezier(0, 0, 0.2, 1),
              opacity 0.25s cubic-bezier(0, 0, 0.2, 1) 0.05s;
}

/* Items do submenu */
.sidebar-submenu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem 0.5rem 1.5rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-submenu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-submenu-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.sidebar-submenu-item.active {
  background: var(--surface-2);
  color: var(--primary-glow);
}

.sidebar-submenu-item.active svg {
  color: var(--primary-glow);
  stroke: var(--primary-glow);
}

/* Logout link dentro do submenu */
.sidebar-submenu-item.sidebar-logout-link {
  color: var(--danger);
}

.sidebar-submenu-item.sidebar-logout-link:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* Modo minimalista - logout com mesmo estilo dos outros items */
[data-style="mono"] .sidebar-submenu-item.sidebar-logout-link {
  color: var(--text-secondary);
}

[data-style="mono"] .sidebar-submenu-item.sidebar-logout-link:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

/* ========================================
   LANGUAGE SELECTOR FLY-OUT
   ======================================== */

.sidebar-language-item {
  position: relative;
}

.sidebar-language-trigger {
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.language-chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

/* Fly-out submenu - appears to the RIGHT */
.sidebar-language-flyout {
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 0.5rem;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  min-width: 120px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-10px);
  transition: all 0.2s ease;
  z-index: 110;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar-language-item:hover .sidebar-language-flyout,
.sidebar-language-item.open .sidebar-language-flyout {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.sidebar-language-item:hover .language-chevron {
  transform: translateX(2px);
}

.language-option {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.language-option:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.language-option.active {
  background: var(--surface-2);
  color: var(--primary-glow);
}

/* Mobile/Tablet adjustments for sidebar - overlay on mobile & iPad vertical */
@media (max-width: 1024px) {
  .app-sidebar {
    width: 100%;
    max-width: 280px;
  }

  .sidebar-toggle-btn {
    top: 0.75rem;
    left: 0.75rem;
    width: 40px;
    height: 40px;
  }

  /* On mobile, keep overlay behavior */
  body.sidebar-open .sidebar-toggle-btn {
    left: 0.75rem;
  }

  body.sidebar-open .main-content,
  body.sidebar-open .container,
  body.sidebar-open .chat-main {
    margin-left: 0;
    padding-left: 0;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Mobile: language fly-out appears below on narrow screens */
  .sidebar-language-flyout {
    position: absolute;
    left: auto;
    right: 0;
    top: 100%;
    margin-left: 0;
    margin-top: 0.25rem;
    width: auto;
    min-width: 120px;
  }

  .sidebar-language-item:hover .language-chevron,
  .sidebar-language-item.open .language-chevron {
    transform: rotate(90deg);
  }
}

/* ========================================
   NOTIFICATION SYSTEM
   Reusable across all pages
   ======================================== */

.notification {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 90%;
  width: auto;
}

.notification.show {
  transform: translateX(-50%) translateY(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.notification-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-icon svg {
  width: 20px;
  height: 20px;
}

.notification-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

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

.notification-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.notification-close {
  display: none;
}

/* Error variant */
.notification.error {
  border-color: rgba(239, 68, 68, 0.3);
  background: linear-gradient(135deg, var(--surface-1) 0%, rgba(239, 68, 68, 0.05) 100%);
}

.notification.error .notification-icon {
  color: var(--danger);
}

.notification.error .notification-title {
  color: var(--danger);
}

/* Success variant */
.notification.success {
  border-color: rgba(16, 185, 129, 0.3);
  background: linear-gradient(135deg, var(--surface-1) 0%, rgba(16, 185, 129, 0.05) 100%);
}

.notification.success .notification-icon {
  color: var(--success);
}

.notification.success .notification-title {
  color: var(--success);
}

/* Warning variant */
.notification.warning {
  border-color: rgba(245, 158, 11, 0.3);
  background: linear-gradient(135deg, var(--surface-1) 0%, rgba(245, 158, 11, 0.05) 100%);
}

.notification.warning .notification-icon {
  color: var(--warning);
}

.notification.warning .notification-title {
  color: var(--warning);
}

/* Info variant */
.notification.info {
  border-color: rgba(59, 130, 246, 0.3);
  background: linear-gradient(135deg, var(--surface-1) 0%, rgba(59, 130, 246, 0.05) 100%);
}

.notification.info .notification-icon {
  color: var(--info);
}

.notification.info .notification-title {
  color: var(--info);
}

/* Mono mode adjustments */
[data-style="mono"] .notification.error,
[data-style="mono"] .notification.success,
[data-style="mono"] .notification.warning,
[data-style="mono"] .notification.info {
  border-color: var(--border-default);
  background: var(--surface-1);
}

[data-style="mono"] .notification .notification-icon,
[data-style="mono"] .notification .notification-title {
  color: var(--text-primary);
}

/* ========================================
   SCROLL LOCK - Block background scroll
   ======================================== */

/* Block scroll when sidebar is open on mobile */
body.sidebar-scroll-lock {
  overflow: hidden !important;
  touch-action: none;
}

/* Block scroll when filter sidebar is open */
body.filters-open {
  overflow: hidden !important;
  touch-action: none;
}

