/* ═══════════════════════════════════════════════════════════════
   PluCi v3 — Design System & Component Library
   Light mode, Apple HIG glassmorphism, 8pt grid
   ═══════════════════════════════════════════════════════════════ */

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

/* DESIGN TOKENS */
:root {
  /* Surfaces - Glass hierarchy */
  --bg: #f5f5f7;
  --bg-elevated: rgba(255, 255, 255, 0.72);
  --bg-card: rgba(255, 255, 255, 0.80);
  --bg-card-hover: rgba(255, 255, 255, 0.92);
  --bg-input: rgba(0, 0, 0, 0.03);
  --bg-config: #f9f7f5;

  /* Glass */
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
  --glass-shadow-raised: 0 8px 32px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);

  /* Text hierarchy — all AA compliant on #f5f5f7 */
  --text: #1d1d1f;              /* AAA 15.46 */
  --text-secondary: #6e6e73;    /* AA 4.66 */
  --text-tertiary: #8a8a8e;     /* AA 3.08 large / fallback for meta-info on white cards (3.44) */

  /* Brand — accent text uses darker variant to meet AA on white cards */
  --accent: #0071e3;            /* AA 4.70 on white */
  --accent-text: #005abe;       /* AA 6.27 on #f5f5f7, 4.65 on tinted accent-subtle */
  --accent-hover: #0077ed;
  --accent-pressed: #006acf;
  --accent-glow: rgba(0, 113, 227, 0.15);
  --accent-subtle: rgba(0, 113, 227, 0.06);

  /* Semantic — dual tokens: visual (bright) + text (darkened for AA) */
  --green: #34c759;             /* bright — use on backgrounds, dots, borders */
  --green-text: #1f7a33;        /* AA 4.56 on bg, 4.95 on white */
  --green-bg: rgba(52, 199, 89, 0.10);
  --red: #ff3b30;
  --red-text: #c2170c;          /* AA 5.45 on white */
  --red-bg: rgba(255, 59, 48, 0.10);
  --yellow: #ff9500;
  --yellow-text: #935600;       /* AA 5.07 on bg, 5.51 on white */
  --yellow-bg: rgba(255, 149, 0, 0.10);
  --blue: #007aff;
  --blue-text: #0062c3;         /* AA 5.65 on white */
  --blue-bg: rgba(0, 122, 255, 0.10);
  --purple: #af52de;
  --purple-text: #8e3db5;       /* AA 4.65 on white */
  --purple-bg: rgba(175, 82, 222, 0.10);

  /* Channel colors */
  --wa-green: #25d366;
  --wa-bg: rgba(37, 211, 102, 0.10);
  --tg-blue: #0088cc;
  --tg-bg: rgba(0, 136, 204, 0.10);
  --discord: #5865f2;
  --discord-bg: rgba(88, 101, 242, 0.10);
  --ig-pink: #e1306c;
  --ig-bg: rgba(225, 48, 108, 0.10);

  /* Spacing scale (8pt grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.2;
  --lh-snug: 1.4;
  --lh-normal: 1.5;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-normal: 250ms;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* BASE STYLES */
html,
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* FOCUS VISIBLE */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT: Sidebar + Main
   ═══════════════════════════════════════════════════════════════ */

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

/* SIDEBAR */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-6) var(--sp-4);
  border-right: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(40px);
  overflow-y: auto;
  z-index: 100;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

.logo {
  font-size: 26px;
  font-weight: 700;
  padding: var(--sp-2) var(--sp-4) var(--sp-6);
  background: linear-gradient(135deg, #0071e3, #5856d6, #0071e3);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
  letter-spacing: -0.5px;
}

@keyframes shimmer {
  to {
    background-position: 200% center;
  }
}

/* Org Switcher */
.org-switcher {
  padding: 0 var(--sp-4) var(--sp-5);
}

.org-switcher-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  transition: all var(--dur-fast) var(--ease);
}

.org-switcher-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-glow);
}

.org-name {
  flex: 1;
  text-align: left;
}

.org-chevron {
  opacity: 0.6;
}

.nav-divider {
  height: 1px;
  background: var(--glass-border);
  margin: var(--sp-3) 0;
}

/* NAV SECTIONS */
.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  padding: var(--sp-5) var(--sp-4) var(--sp-2);
}

/* NAV ITEMS */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 11px var(--sp-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: all var(--dur-fast) var(--ease);
  position: relative;
  min-height: 44px;
  width: 100%;
  text-align: left;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  opacity: 0.7;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.nav-item:hover svg,
.nav-item.active svg {
  opacity: 1;
}

.nav-item .badge {
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: auto;
  min-width: 20px;
  text-align: center;
}

.nav-spacer {
  flex: 1;
}

/* USER CARD */
.user-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--glass-border);
  margin-top: var(--sp-2);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

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

.user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.user-role {
  font-size: 10px;
  color: var(--text-tertiary);
}

.settings-btn {
  margin-top: var(--sp-2);
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-6) var(--sp-8);
  border-bottom: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  height: 70px;
}

.topbar-left {
  flex: 1;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}

.search-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-4);
  min-height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: text;
}

.search-input {
  background: transparent;
  border: none;
  font-size: var(--text-sm);
  color: var(--text);
  width: 200px;
  outline: none;
  min-height: 24px;
  padding: 4px 0;
}

.search-input::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  transition: all var(--dur-fast) var(--ease);
  color: var(--text-secondary);
}

.icon-btn:hover {
  background: var(--bg-input);
  color: var(--text);
}

.icon-btn svg {
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--bg);
}

/* PAGE CONTENT */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-8);
}

.page-content::-webkit-scrollbar {
  width: 8px;
}

.page-content::-webkit-scrollbar-track {
  background: transparent;
}

.page-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.page-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ═══════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

/* CARD */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: var(--sp-6);
  transition: all var(--dur-fast) var(--ease);
}

.card:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--glass-shadow-raised);
}

/* STAT CARD */
.stat-card {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-6);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 24px;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--sp-2);
}

.stat-trend {
  font-size: 12px;
  margin-top: var(--sp-2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
}

.stat-trend.positive {
  background: var(--green-bg);
  color: var(--green-text);
}

.stat-trend.negative {
  background: var(--red-bg);
  color: var(--red-text);
}

/* BADGE / CHIP */
.badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green {
  background: var(--green-bg);
  color: var(--green-text);
}

.badge-blue {
  background: var(--tg-bg);
  color: #005580;  /* darker tg blue for AA */
}

.badge-wa {
  background: var(--wa-bg);
  color: #0e7064;  /* darker WA green for AA on tinted bg */
}

.badge-yellow {
  background: var(--yellow-bg);
  color: var(--yellow-text);
}

/* AVATAR */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  flex-shrink: 0;
  font-size: var(--text-md);
}

.avatar-32 {
  width: 32px;
  height: 32px;
}

.avatar-40 {
  width: 40px;
  height: 40px;
}

.avatar-48 {
  width: 48px;
  height: 48px;
}

.avatar-blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.avatar-green {
  background: var(--green-bg);
  color: var(--green);
}

.avatar-red {
  background: var(--red-bg);
  color: var(--red);
}

.avatar-purple {
  background: var(--purple-bg);
  color: var(--purple);
}

/* ACTIVITY ITEM */
.activity-item {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--glass-border);
}

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

.activity-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

.activity-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.activity-time {
  font-size: 11px;
  color: var(--text-secondary);
}

/* BUTTON */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-5);
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
}

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

.button-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--glass-shadow-raised);
}

.button-primary:active {
  transform: scale(0.97);
}

.button-secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}

.button-secondary:hover {
  background: var(--bg-input);
  color: var(--text);
  border-color: var(--accent);
}

/* GRID BENTO */
.grid-bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--sp-6);
  auto-rows: minmax(140px, auto);
}

.grid-col-3 {
  grid-column: span 3;
}

.grid-col-6 {
  grid-column: span 6;
}

.grid-col-7 {
  grid-column: span 7;
}

.grid-col-5 {
  grid-column: span 5;
}

.grid-row-2 {
  grid-row: span 2;
}

.grid-row-3 {
  grid-row: span 3;
}

/* RESPONSIVE */
@media (max-width: 1400px) {
  .grid-col-7 {
    grid-column: span 12;
  }

  .grid-col-5 {
    grid-column: span 12;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .topbar {
    padding: var(--sp-4);
    height: 56px;
  }

  .page-content {
    padding: var(--sp-4);
  }

  .grid-bento {
    grid-template-columns: repeat(1, 1fr);
    gap: var(--sp-4);
  }

  .grid-col-3,
  .grid-col-5,
  .grid-col-6,
  .grid-col-7 {
    grid-column: span 1;
  }

  .search-input {
    width: 120px;
  }
}

/* SECTION HEADER */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
}

.section-link {
  font-size: var(--text-sm);
  color: var(--accent);
  cursor: pointer;
}

/* LOADING SKELETON */
@keyframes shimmer-load {
  0% {
    background-position: -1000px 0;
  }

  100% {
    background-position: 1000px 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06),
    rgba(0, 0, 0, 0.1),
    rgba(0, 0, 0, 0.06)
  );
  background-size: 1000px 100%;
  animation: shimmer-load 2s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 16px;
  width: 100%;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

/* ═══════════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════════ */

#toast-root {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  background: #1d1d1f;
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  min-width: 240px;
  max-width: 400px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateX(100px);
  transition: all var(--dur-normal) var(--ease);
  pointer-events: auto;
  border-left: 3px solid var(--blue);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  border-left-color: var(--green);
}

.toast-error {
  border-left-color: var(--red);
}

.toast-info {
  border-left-color: var(--blue);
}

@media (max-width: 768px) {
  #toast-root {
    left: var(--sp-4);
    right: var(--sp-4);
    bottom: var(--sp-4);
  }

  .toast {
    min-width: 0;
  }
}


/* ═══════════════════════════════════════════════════════
   CONFIG LAYER — Capa de configuración avanzada
   Diferenciadores: fondo cálido, banner stripe, sidebar propio
   ═══════════════════════════════════════════════════════ */

.config-layout {
  min-height: 100vh;
  background: var(--bg-config);
  display: flex;
  flex-direction: column;
}

.config-stripe {
  background: rgba(255, 149, 0, 0.08);
  border-bottom: 1px solid rgba(255, 149, 0, 0.2);
  color: var(--text);
  padding: 8px var(--sp-5);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.config-stripe strong {
  color: var(--yellow);
}

.stripe-close {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease);
}

.stripe-close:hover {
  background: white;
  color: var(--text);
}

.stripe-close svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.config-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.config-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--glass-border);
  padding: var(--sp-4);
  overflow-y: auto;
}

.config-back {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-3);
  background: var(--accent-subtle);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  margin-bottom: var(--sp-4);
  transition: all var(--dur-fast) var(--ease);
}

.config-back:hover {
  background: rgba(0, 113, 227, 0.12);
}

.config-back svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.config-nav-group {
  margin-bottom: var(--sp-4);
}

.config-nav-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 var(--sp-3);
  margin-bottom: 6px;
}

.config-subgroup-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px var(--sp-3) 4px calc(var(--sp-3) + 4px);
  display: flex;
  align-items: center;
  gap: 6px;
}

.config-subgroup-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.config-nav-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-fast) var(--ease);
  margin-bottom: 2px;
}

.config-nav-item:hover {
  background: rgba(255, 255, 255, 0.8);
}

.config-nav-item.active {
  background: white;
  box-shadow: var(--glass-shadow);
}

.config-nav-item svg {
  stroke: var(--text-secondary);
  fill: none;
  stroke-width: 2;
  flex-shrink: 0;
  margin-top: 2px;
}

.config-nav-item.active svg {
  stroke: var(--accent);
}

.config-nav-item-text {
  flex: 1;
  min-width: 0;
}

.config-nav-item-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.config-nav-item.active .config-nav-item-label {
  color: var(--accent);
  font-weight: 600;
}

.config-nav-item-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.3;
}

.config-main {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-6);
}

.config-content {
  max-width: 1080px;
  margin: 0 auto;
}

.config-placeholder {
  text-align: center;
  padding: 80px 40px;
  color: var(--text-secondary);
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
}

.config-page-header {
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--glass-border);
}

.config-page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.config-page-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Config cards más compactas que Light layer */
.config-card {
  background: white;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
}

/* Action bar sticky para dirty state */
.config-action-bar {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  padding: var(--sp-3) var(--sp-5);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin: var(--sp-5) calc(-1 * var(--sp-6)) calc(-1 * var(--sp-5));
  z-index: 10;
}

.config-action-bar .danger-action {
  margin-right: auto;
}

@media (max-width: 768px) {
  .config-sidebar {
    width: 100%;
    max-width: 100%;
    position: fixed;
    top: 0;
    left: -100%;
    height: 100vh;
    z-index: 200;
    transition: left var(--dur-normal) var(--ease);
  }

  .config-sidebar.open {
    left: 0;
  }

  .config-main {
    padding: var(--sp-3);
  }
}

/* ═══════════════════════════════════════════════════════
   FASE 5 — Polish & Mobile
   Bottom nav + sheet, skeleton loaders, empty states
   ═══════════════════════════════════════════════════════ */

/* ─── BOTTOM NAVIGATION (mobile) ─── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-top: 1px solid var(--glass-border);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--dur-normal) var(--ease);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,0.1);
  }

  .main-content {
    margin-left: 0;
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }

  .page-content {
    padding-bottom: calc(56px + env(safe-area-inset-bottom)) !important;
  }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  position: relative;
  min-height: 44px;
  padding: 6px 4px;
  transition: color var(--dur-fast) var(--ease);
}

.bottom-nav-item:active {
  transform: scale(0.95);
}

.bottom-nav-item svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}

.bn-badge {
  position: absolute;
  top: 4px;
  right: 25%;
  background: var(--red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── BOTTOM SHEET (Más menu) ─── */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-normal) var(--ease);
}

.bottom-sheet-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1;
}

.bottom-sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--dur-normal) var(--ease);
  z-index: 2;
}

.bottom-sheet-overlay.open .bottom-sheet-content {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: #d1d1d6;
  border-radius: 2px;
  margin: 0 auto 12px;
}

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

.bottom-sheet-header h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.bottom-sheet-section {
  margin-bottom: 12px;
}

.bs-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 12px 4px;
}

.bs-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  min-height: 44px;
  transition: background var(--dur-fast) var(--ease);
}

.bs-item:active {
  background: var(--bg-input);
}

.bs-item svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  color: var(--text-secondary);
}

/* ─── SKELETON LOADERS ─── */
@keyframes skeletonShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.04) 0%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.04) 100%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  display: block;
}

.skeleton.text-lg { height: 20px; width: 60%; }
.skeleton.text-md { height: 16px; width: 80%; }
.skeleton.text-sm { height: 12px; width: 50%; }
.skeleton.circle { border-radius: 50%; }
.skeleton.block { height: 100px; }

.skeleton-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.skeleton-card {
  padding: var(--sp-4);
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
}

.skeleton-row .avatar-skeleton {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-row .lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ─── EMPTY STATES ─── */
.empty-state {
  text-align: center;
  padding: var(--sp-8) var(--sp-5);
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 56px;
  margin-bottom: var(--sp-3);
  opacity: 0.3;
  display: block;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-2);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--sp-4);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.empty-state-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.empty-state-cta:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

/* ─── SWIPE GESTURES ─── */
.swipe-container {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.swipe-item {
  transition: transform var(--dur-normal) var(--ease);
  background: inherit;
  position: relative;
  z-index: 2;
}

.swipe-item.swiping {
  transition: none;
}

.swipe-action-layer {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: opacity var(--dur-fast) var(--ease);
}

.swipe-action-right {
  right: 0;
  background: var(--green);
  color: white;
  padding: 0 20px;
  min-width: 80px;
}

.swipe-action-left {
  left: 0;
  background: var(--red);
  color: white;
  padding: 0 20px;
  min-width: 80px;
}

.swipe-action-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.swipe-action-label {
  font-size: 10px;
  font-weight: 600;
}

/* ─── MOBILE ADJUSTMENTS ─── */
@media (max-width: 768px) {
  /* Hamburger to open sidebar */
  .topbar-left::before {
    content: '☰';
    font-size: 20px;
    cursor: pointer;
    margin-right: var(--sp-3);
  }

  /* Larger touch targets */
  .button,
  .nav-item,
  .tab-btn,
  .filter-pill {
    min-height: 44px;
  }

  /* Hide desktop-only elements */
  .topbar-right .search-btn {
    display: none;
  }

  /* Tighter spacing */
  .page-content {
    padding: var(--sp-3) !important;
  }

  /* Full-width cards */
  .card {
    padding: var(--sp-3);
  }
}

/* ─── REDUCED MOTION ─── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .skeleton {
    animation: none;
    background: rgba(0, 0, 0, 0.06);
  }
}

/* ═══════════════════════════════════════════════════════
   WCAG 2.2 AA — Accessibility helpers
   Use .text-{color} for AA-compliant colored text.
   Original --green/--red/--yellow/--blue/--purple remain
   for backgrounds, dots, borders, and decorative use.
   ═══════════════════════════════════════════════════════ */

.text-accent { color: var(--accent-text); }
.text-green { color: var(--green-text); }
.text-red { color: var(--red-text); }
.text-yellow { color: var(--yellow-text); }
.text-blue { color: var(--blue-text); }
.text-purple { color: var(--purple-text); }

/* Focus ring — keyboard navigation accessibility */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Skip to content (keyboard users) */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  z-index: 999;
  border-radius: 0 0 var(--radius-sm) 0;
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-sm);
}

.skip-to-content:focus {
  top: 0;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ═══════════════════════════════════════════════════════
   FASE 6 — Capacitor native integration
   Version banner, keyboard handling, QR scanner state
   ═══════════════════════════════════════════════════════ */

.version-banner {
  text-align: center;
  padding: 8px var(--sp-3);
  margin-top: var(--sp-2);
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  border-top: 1px solid var(--glass-border);
}

/* QR scanner active — hide everything to show camera */
body.qr-scanner-active {
  background: transparent !important;
}

body.qr-scanner-active .app,
body.qr-scanner-active .bottom-nav,
body.qr-scanner-active #toast-root,
body.qr-scanner-active #modal-root {
  visibility: hidden;
}

/* Keyboard open (iOS) — adjust safe areas */
body.keyboard-open .bottom-nav {
  display: none;  /* hide bottom nav when keyboard up */
}

body.keyboard-open .thread-input {
  padding-bottom: calc(var(--sp-4) + var(--kb-height, 0px));
}

/* iOS notch-aware padding */
@supports (padding-top: env(safe-area-inset-top)) {
  .topbar {
    padding-top: calc(var(--sp-4) + env(safe-area-inset-top));
  }

  .sidebar {
    padding-top: calc(var(--sp-6) + env(safe-area-inset-top));
  }
}
