/* ═══════════════════════════════════════════════════════════════
   phase1-design.css — Grafo · Fase 1 Design Upgrade
   ───────────────────────────────────────────────────────────────
   1. Whiteboard cards premium
   2. Empty states con ilustración SVG animada
   3. Tipografía & jerarquía visual
   4. Sidebar depth & contrast
   5. Accent color wiring (ya en --primary, solo estética)
   6. Block hover states premium
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   1. WHITEBOARD CARDS PREMIUM
   ───────────────────────────────────────────────────────────── */

.wb-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.wb-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
  transition:
    border-color  0.22s cubic-bezier(0.16, 1, 0.3, 1),
    transform     0.28s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow    0.28s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, box-shadow;
}

/* Borde top sutil estilo premium */
.wb-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.12) 30%,
    rgba(255,255,255,0.22) 50%,
    rgba(255,255,255,0.12) 70%,
    transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
}

/* Glow de hover — sigue el cursor vía JS en el futuro, estático por ahora */
.wb-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 0%,
    rgba(var(--primary-rgb, 91, 141, 239), 0.06) 0%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: inherit;
  pointer-events: none;
}

.wb-card:hover {
  transform: translateY(-6px) scale(1.008);
  border-color: rgba(255,255,255,0.18);
  box-shadow:
    0 1px 2px rgba(0,0,0,0.08),
    0 8px 20px rgba(0,0,0,0.16),
    0 20px 40px rgba(0,0,0,0.12),
    0 0 0 0.5px rgba(255,255,255,0.08) inset;
}

.wb-card:hover::before { opacity: 1; }
.wb-card:hover::after  { opacity: 1; }

[data-theme="light"] .wb-card:hover {
  box-shadow:
    0 1px 2px rgba(15,18,28,0.04),
    0 8px 20px rgba(15,18,28,0.10),
    0 20px 40px rgba(15,18,28,0.07);
  border-color: rgba(0,0,0,0.14);
}

.wb-card:active {
  transform: translateY(-2px) scale(1.002);
  transition-duration: 0.08s;
}

/* Thumbnail — gradiente de profundidad */
.wb-thumb {
  height: 172px;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 14px;
  position: relative;
}

/* Ruido de textura muy sutil sobre el thumbnail */
.wb-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.4;
}

/* Badge: número de elementos */
.wb-count-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.85);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.2px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.10);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.2s, transform 0.2s;
}

.wb-card:hover .wb-count-badge {
  opacity: 1;
  transform: translateY(0);
}

[data-theme="light"] .wb-count-badge {
  background: rgba(255,255,255,0.72);
  color: rgba(0,0,0,0.7);
  border-color: rgba(0,0,0,0.08);
}

/* Texto vacío mejorado */
.wb-thumb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.wb-thumb-empty::before {
  content: '';
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--border);
  display: block;
  /* Cuadro de borrador vacío */
  background-image:
    linear-gradient(45deg, var(--border) 25%, transparent 25%),
    linear-gradient(-45deg, var(--border) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--border) 75%),
    linear-gradient(-45deg, transparent 75%, var(--border) 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
  opacity: 0.4;
}

/* Meta info */
.wb-card-meta { padding: 14px 16px 10px; }

.wb-card-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.1px;
}

.wb-card-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wb-card-sub::before {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}

/* Actions row */
.wb-card-acts {
  display: flex;
  gap: 5px;
  padding: 0 14px 13px;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.wb-card:hover .wb-card-acts {
  opacity: 1;
  transform: translateY(0);
}

/* ─────────────────────────────────────────────────────────────
   2. EMPTY STATES CON ILUSTRACIÓN SVG ANIMADA
   ───────────────────────────────────────────────────────────── */

.wb-empty {
  padding: 80px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  grid-column: 1 / -1;
}

/* Ilustración SVG vacío inline */
.wb-empty::before {
  content: '';
  display: block;
  width: 80px;
  height: 80px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80' fill='none'%3E%3Crect x='10' y='18' width='60' height='44' rx='8' stroke='%23555' stroke-width='1.5' stroke-dasharray='5 3'/%3E%3Ccircle cx='25' cy='37' r='6' stroke='%23555' stroke-width='1.5'/%3E%3Cpath d='M35 40 Q45 30 55 38 Q60 42 65 36' stroke='%23555' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='M10 52 Q25 42 35 48 Q45 54 55 44 Q62 38 70 42' stroke='%23555' stroke-width='1.5' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation: wb-empty-float 3.5s ease-in-out infinite;
  opacity: 0.55;
}

@keyframes wb-empty-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.wb-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.1px;
}

.wb-empty-sub {
  font-size: 13px;
  color: var(--text-3);
  max-width: 260px;
  line-height: 1.55;
}

/* ─────────────────────────────────────────────────────────────
   3. TIPOGRAFÍA & JERARQUÍA VISUAL
   ───────────────────────────────────────────────────────────── */

/* Título de página — más presencia y elegancia */
.page-title {
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.8px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .page-title {
  /* Sutil gradient en el texto del título en dark mode */
  background: linear-gradient(135deg, var(--text) 40%, color-mix(in srgb, var(--text) 70%, var(--primary)) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Headings más definidos */
.block-h1 .editable {
  font-size: clamp(24px, 3.5vw, 32px);
  font-weight: 720;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.block-h2 .editable {
  font-size: clamp(20px, 2.8vw, 26px);
  font-weight: 650;
  letter-spacing: -0.3px;
  line-height: 1.25;
}

.block-h3 .editable {
  font-size: clamp(17px, 2.2vw, 21px);
  font-weight: 620;
  letter-spacing: -0.15px;
  line-height: 1.3;
}

/* Heading top-margin más generoso para respirar */
.block-h1 { margin-top: 20px; }
.block-h2 { margin-top: 14px; }
.block-h3 { margin-top: 10px; }

/* Body text — mejor line-height */
.editable {
  line-height: var(--line-height, 1.65);
  font-size: 15.5px;
}

/* Placeholder más discreto */
.editable[data-empty="true"][data-focused="true"]:before {
  color: var(--text-light);
  font-style: italic;
  font-weight: 400;
}

/* Nombres de páginas en la sidebar más legibles */
.tree-row .tr-title {
  font-size: 13.5px;
  letter-spacing: -0.05px;
}

/* Texto secundario un poco más cálido */
.wb-card-sub,
.tree-row .tr-title,
.sb-item {
  font-size: 13.5px;
}

/* ─────────────────────────────────────────────────────────────
   4. SIDEBAR DEPTH & CONTRAST
   ───────────────────────────────────────────────────────────── */

/* Dark mode: la sidebar tiene que distinguirse del main — bg levemente más oscuro */
[data-theme="dark"] .sidebar {
  background: #131313;
  border-right-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .sidebar-inner {
  background: #131313;
}

/* Workspace switcher en dark: un poco más de contraste */
[data-theme="dark"] .workspace-switcher {
  border-radius: 8px;
}

[data-theme="dark"] .workspace-switcher:hover {
  background: rgba(255,255,255,0.06);
}

/* Section headers más legibles */
.sb-section-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 6px 10px 4px;
}

/* Tree rows — active state más claro y con barra */
.tree-row.active {
  background: color-mix(in srgb, var(--primary) 10%, transparent) !important;
}

.tree-row.active .tr-title {
  color: var(--text);
  font-weight: 550;
}

.tree-row.active::before {
  background: var(--primary) !important;
  transform: scaleY(0.65) !important;
}

/* sb-item active — coherente con tree-row */
.sb-item.active {
  background: color-mix(in srgb, var(--primary) 10%, transparent) !important;
  color: var(--text);
  font-weight: 550;
}

/* Hover en dark más sutil */
[data-theme="dark"] .tree-row:hover {
  background: rgba(255,255,255,0.05) !important;
}

[data-theme="dark"] .sb-item:hover {
  background: rgba(255,255,255,0.05) !important;
}

/* Scrollbar de sidebar más fina y elegante */
.sidebar-inner::-webkit-scrollbar { width: 4px; }
.sidebar-inner::-webkit-scrollbar-thumb {
  background: rgba(128,128,128,0.2);
  border-radius: 2px;
}
.sidebar-inner::-webkit-scrollbar-thumb:hover {
  background: rgba(128,128,128,0.38);
}

/* Separadores entre secciones */
.sidebar-section + .sidebar-section {
  border-top: 1px solid rgba(128,128,128,0.08);
  padding-top: 6px;
  margin-top: 2px;
}

/* ─────────────────────────────────────────────────────────────
   5. ACCENT COLOR — ESTÉTICA EXTRA (el valor ya lo pone JS)
      Aplicamos el color en lugares adicionales que JS no toca
   ───────────────────────────────────────────────────────────── */

/* Checkbox todo con accent */
.block-todo .todo-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* Cursor de texto en editables */
.editable { caret-color: var(--primary); }

/* Barra lateral activa en sidebar */
.tree-row.active::before {
  background: var(--primary) !important;
}

/* Quote border con accent */
.block-quote .block-content {
  border-left-color: var(--primary);
  border-left-width: 3px;
}

/* Selección de texto */
::selection {
  background: color-mix(in srgb, var(--primary) 25%, transparent);
  color: inherit;
}

/* Focus ring en botones primarios */
.wb-btn-primary {
  background: var(--text) !important;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 30%, transparent);
  transition: box-shadow 0.2s, opacity 0.15s !important;
}

.wb-btn-primary:hover {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent) !important;
}

/* ─────────────────────────────────────────────────────────────
   6. BLOCK HOVER STATES PREMIUM
   ───────────────────────────────────────────────────────────── */

/* Hover sutil — solo un fondo muy tenue */
.block:hover > .block-row {
  background: color-mix(in srgb, var(--text) 2.5%, transparent);
  border-radius: 5px;
}

[data-theme="dark"] .block:hover > .block-row {
  background: rgba(255,255,255,0.025);
}

/* Handle aparece con transición suave */
.block-handle {
  opacity: 0;
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.block:hover > .block-row > .block-handle,
.block:focus-within > .block-row > .block-handle {
  opacity: 1;
}

/* Botones del handle más bonitos */
.block-handle .bh-btn {
  width: 20px; height: 24px;
  border-radius: 5px;
  color: var(--text-3);
  transition: background 0.12s, color 0.12s, transform 0.15s;
}

.block-handle .bh-btn:hover {
  background: var(--hover-strong);
  color: var(--text-2);
  transform: scale(1.1);
}

/* Línea de inserción de bloque — más visible */
.block.drop-above::before,
.block.drop-below::after {
  height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent 90%);
  border-radius: 1px;
}

/* Foco en editable — ring muy sutil */
.editable[data-focused="true"] {
  background: linear-gradient(to right,
    transparent 0%,
    color-mix(in srgb, var(--primary) 4%, transparent) 50%,
    transparent 100%
  ) !important;
}

/* ─────────────────────────────────────────────────────────────
   7. TOPBAR REFINEMENTS
   ───────────────────────────────────────────────────────────── */

/* Topbar sutil border-bottom solo cuando hay scroll */
.topbar {
  transition: box-shadow 0.2s ease;
}

.topbar.scrolled {
  box-shadow: 0 1px 0 var(--border),
              0 4px 12px rgba(0,0,0,0.06);
}

/* Breadcrumb más legible */
.bc-item {
  font-size: 13.5px;
  border-radius: 5px;
  transition: background 0.12s, color 0.12s;
}

.bc-item.current {
  font-weight: 600;
  color: var(--text);
}

.bc-sep {
  font-size: 13px;
  color: var(--text-3);
  opacity: 0.6;
}

/* ─────────────────────────────────────────────────────────────
   8. WHITEBOARD EDITOR TOOLBAR — refinements
   ───────────────────────────────────────────────────────────── */

/* Toolbar con separación visual entre grupos */
.wb-toolbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

/* Tool activo más legible */
.wb-tool.active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
  border-radius: 7px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent) inset;
}

/* ─────────────────────────────────────────────────────────────
   9. SCROLL SUAVE EN EL EDITOR
   ───────────────────────────────────────────────────────────── */

.editor-scroll {
  scroll-behavior: smooth;
}

/* ─────────────────────────────────────────────────────────────
   10. PAGE TITLE — underline accent al enfocar
   ───────────────────────────────────────────────────────────── */

.page-title {
  position: relative;
}

.page-title:focus::after {
  width: 80px !important;
  background: linear-gradient(90deg, var(--primary), transparent) !important;
  opacity: 0.7;
}

/* ─────────────────────────────────────────────────────────────
   11. BOTONES DE ACCIÓN GLOBALES — polish final
   ───────────────────────────────────────────────────────────── */

/* Todos los icon-btn con transición de color */
.icon-btn {
  transition: background 0.14s ease, color 0.14s ease, transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-btn:hover {
  transform: scale(1.08);
}

.icon-btn:active {
  transform: scale(0.94);
  transition-duration: 0.06s;
}

/* ─────────────────────────────────────────────────────────────
   12. REDUCED MOTION — respeta preferencia del usuario
   ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .wb-card,
  .wb-empty::before,
  .icon-btn,
  .block-handle,
  .wb-card::before,
  .wb-card::after,
  .wb-card-acts {
    animation: none !important;
    transition: none !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   13. LIGHT MODE — ajustes específicos
   ───────────────────────────────────────────────────────────── */

[data-theme="light"] .sidebar {
  background: #f9f9f7;
  border-right-color: #e5e5e3;
}

[data-theme="light"] .tree-row.active {
  background: color-mix(in srgb, var(--primary) 8%, transparent) !important;
}

[data-theme="light"] .wb-card:hover {
  border-color: rgba(0,0,0,0.12);
}

[data-theme="light"] .page-title {
  background: none;
  -webkit-text-fill-color: var(--text);
}

/* ─────────────────────────────────────────────────────────────
   14. TOPBAR SCROLL DETECTION VIA JS (clase CSS lista)
   ───────────────────────────────────────────────────────────── */

/* Se activa con JS: editorScroll.addEventListener('scroll') → toggle 'scrolled' en topbar */
.topbar.has-scroll-shadow {
  border-bottom-color: var(--border);
  box-shadow:
    0 1px 0 var(--border),
    0 2px 8px rgba(0,0,0,0.06);
}

[data-theme="dark"] .topbar.has-scroll-shadow {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06),
    0 2px 12px rgba(0,0,0,0.25);
}
