:root {
  --waclis-magenta: #e1007a;
  --waclis-purple: #7b2cbf;
  --waclis-blue: #0077b6;
  --waclis-cyan: #00b4d8;
  --waclis-gradient: linear-gradient(135deg, #e1007a 0%, #7b2cbf 50%, #00b4d8 100%);
  --waclis-gradient-hover: linear-gradient(135deg, #f72585 0%, #9d4edd 50%, #48cae4 100%);
  
  /* Sistema de Color Claro Universal Waclis Connect */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: rgba(0, 180, 216, 0.5);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-card-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-dropdown: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --transition-smooth: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Background Ambient Elements (limpios en modo claro) */
.ambient-glow-top,
.ambient-glow-bottom {
  display: none;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 2rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
}

.nav-logo-img {
  height: 36px;
  object-fit: contain;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Organization Selector */
.org-selector-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
}

.org-selector-container:hover {
  border-color: var(--border-strong);
}

.org-select {
  background: transparent;
  color: var(--text-primary);
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.org-select option {
  background: #ffffff;
  color: var(--text-primary);
}

/* App Switcher Button (9 dots) */
.btn-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-switcher:hover {
  border-color: var(--waclis-blue);
  background: #f1f5f9;
  transform: translateY(-1px);
}

.switcher-grid-icon {
  display: grid;
  grid-template-columns: repeat(3, 4px);
  gap: 3px;
}

.switcher-dot {
  width: 4px;
  height: 4px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: var(--transition-smooth);
}

.btn-switcher:hover .switcher-dot {
  background: var(--waclis-blue);
}

/* User Badge */
.user-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
}

.user-avatar {
  width: 28px;
  height: 28px;
  background: var(--waclis-gradient);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
  box-shadow: 0 2px 4px rgba(225, 0, 122, 0.2);
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}

.btn-logout:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* Main Container & Tabs */
.main-container {
  position: relative;
  max-width: 1200px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  z-index: 1;
}

.header-banner {
  margin-bottom: 2rem;
}

.header-banner h1 {
  font-size: 2.25rem;
  font-weight: 700;
  background: var(--waclis-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.header-banner p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.nav-tabs {
  display: flex;
  gap: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  padding: 0.75rem 0.5rem;
  cursor: pointer;
  position: relative;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--text-primary);
  font-weight: 600;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--waclis-gradient);
}

/* Apps Grid */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.app-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-card);
}

.app-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.app-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.app-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.app-icon-img {
  width: 32px;
  height: 32px;
  display: block;
  object-fit: contain;
}

.switcher-icon-img {
  width: 24px;
  height: 24px;
  display: block;
  object-fit: contain;
}

.app-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-enabled {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-plan,
.badge-plan_required {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-disabled {
  background: #f1f5f9;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.app-info h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.app-info p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 1.5rem;
  min-height: 45px;
}

.app-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-launch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
}

.btn-primary {
  background: var(--waclis-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(225, 0, 122, 0.25);
}

.btn-primary:hover {
  background: var(--waclis-gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 180, 216, 0.35);
}

.btn-disabled {
  background: #f1f5f9;
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
}

.btn-disabled:hover {
  background: #e2e8f0;
  color: var(--text-secondary);
}

/* Universal App Switcher Dropdown */
.switcher-modal {
  position: absolute;
  top: 70px;
  right: 2rem;
  width: 360px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-dropdown);
  display: none;
  z-index: 200;
  animation: fadeIn 0.15s ease-out;
}

.switcher-modal.open {
  display: block;
}

.switcher-header {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.switcher-apps-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.switcher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition-smooth);
}

.switcher-item:hover {
  background: var(--bg-secondary);
}

.switcher-item-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.4rem;
  padding: 6px;
}

.switcher-item-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
}

.switcher-item.is-current {
  background: var(--bg-secondary);
}

.switcher-item.is-current .switcher-item-icon {
  border-color: #cbd5e1;
  background: #ffffff;
}

.switcher-current-badge {
  font-size: 9px;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 1px 5px;
  border-radius: 4px;
  margin-top: 3px;
  letter-spacing: 0.02em;
}

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

/* Waclis Native Modal Component */
.waclis-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  padding: 1rem;
}

.waclis-modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.waclis-modal-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.waclis-modal-backdrop.open .waclis-modal-card {
  transform: scale(1) translateY(0);
}

.waclis-modal-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1.5rem 1.5rem 0.75rem;
}

.waclis-modal-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.waclis-modal-icon.info {
  background: rgba(0, 180, 216, 0.1);
  border-color: rgba(0, 180, 216, 0.25);
  color: var(--waclis-blue);
}

.waclis-modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.waclis-modal-body {
  padding: 0.5rem 1.5rem 1.5rem;
}

.waclis-modal-body p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.waclis-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
}

.waclis-btn {
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.waclis-btn-secondary {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

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

.waclis-btn-danger {
  background: var(--danger);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.waclis-btn-danger:hover {
  background: #b91c1c;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
}

.waclis-btn-primary {
  background: var(--waclis-gradient);
  color: #ffffff;
}

.waclis-btn-primary:hover {
  background: var(--waclis-gradient-hover);
}

/* Pantalla de Error Controlado (Anti-Loop) */
.error-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
}

.error-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-dropdown);
  animation: fadeIn 0.3s ease-out;
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.error-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.error-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.error-correlation {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  word-break: break-all;
}

.btn-retry {
  background: var(--waclis-gradient);
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  width: 100%;
}

.btn-retry:hover {
  background: var(--waclis-gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -4px rgba(0, 180, 216, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .nav-controls {
    gap: 0.75rem;
  }
  .apps-grid {
    grid-template-columns: 1fr;
  }
  .switcher-modal {
    right: 1rem;
    left: 1rem;
    width: auto;
  }
  .header-banner h1 {
    font-size: 1.75rem;
  }
}

@media (max-width: 480px) {
  .navbar {
    padding: 0.6rem 0.85rem;
  }
  .nav-logo-img {
    height: 30px;
  }
  .nav-controls {
    gap: 0.5rem;
  }
  .org-selector-container {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
  }
  .org-select {
    font-size: 0.8rem;
    max-width: 110px;
  }
  .user-badge {
    padding: 0.25rem 0.5rem;
  }
  .user-name {
    display: none;
  }
  .header-banner h1 {
    font-size: 1.5rem;
  }
}
