/* ==========================================================================
   Pizarra Mágica Infantil - Estilos Divertidos, Limpios y Táctiles
   ========================================================================== */

:root {
  --bg-app: #0f1026;
  --bg-surface: rgba(26, 27, 60, 0.88);
  --bg-canvas: #161736;
  --border-color: rgba(255, 255, 255, 0.12);
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;

  --pink: #ec4899;
  --purple: #8b5cf6;
  --blue: #3b82f6;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;

  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.6);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Comic Sans MS", "Chalkboard SE", sans-serif;
  user-select: none;
}

.app-layout {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* ==========================================================================
   Pantalla de Bienvenida: Selección de las 4 Salas
   ========================================================================== */

.room-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #1e1b4b 0%, #09081a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 24px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.room-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.room-screen-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 720px;
  width: 100%;
}

.bounce-title {
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(135deg, #f472b6, #c084fc, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gentleBounce 2s infinite ease-in-out;
}

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

.room-screen-subtitle {
  font-size: 18px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
}

.rooms-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  width: 100%;
}

.room-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 18px;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-md);
  color: #fff;
  outline: none;
}

.room-card:hover, .room-card:focus {
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}

.room-card:active {
  transform: scale(0.97);
}

.room-card-emoji {
  font-size: 54px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.room-card-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.room-card-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Colores Temáticos de las 4 Salas */
.card-unicornio {
  background: linear-gradient(135deg, #ec4899, #a855f7);
  border-color: #f472b6;
}
.card-princesas {
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  border-color: #fbbf24;
}
.card-arcoiris {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  border-color: #38bdf8;
}
.card-estrellas {
  background: linear-gradient(135deg, #8b5cf6, #4f46e5);
  border-color: #a78bfa;
}

/* ==========================================================================
   Toolbar Superior
   ========================================================================== */

.toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 100;
}

.btn-room {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.25), rgba(139, 92, 246, 0.25));
  border: 2px solid #ec4899;
  border-radius: 30px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-room:hover {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.4);
}

.btn-room-arrow {
  font-size: 13px;
  opacity: 0.8;
}

.divider {
  width: 1px;
  height: 28px;
  background-color: var(--border-color);
  margin: 0 2px;
}

/* ==========================================================================
   Botones de Herramientas
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  transform: scale(1.05);
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-tool.active {
  background: var(--pink);
  border-color: #f472b6;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(236, 72, 153, 0.5);
}

.btn-stickers {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(236, 72, 153, 0.2));
  border-color: #f59e0b;
  color: #fde047;
}

.btn-stickers:hover, .btn-stickers.active {
  background: #f59e0b;
  color: #1e1b4b;
  font-weight: 800;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
}

.btn-icon {
  width: 38px;
  padding: 0;
}

.btn-warning {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #fcd34d;
}

.btn-success {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
  color: #6ee7b7;
}

.btn-install {
  background: rgba(139, 92, 246, 0.25);
  border-color: #8b5cf6;
  color: #c4b5fd;
}

/* ==========================================================================
   Selector de Color y Paleta Rápida
   ========================================================================== */

.color-group {
  gap: 8px;
}

.color-picker-wrapper {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
  overflow: hidden;
  cursor: pointer;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-picker-wrapper input[type="color"] {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 48px;
  height: 48px;
  border: none;
  cursor: pointer;
  background: transparent;
}

.palette-swatches {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: var(--c);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.swatch:hover {
  transform: scale(1.25);
}

.swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 10px var(--c), inset 0 0 0 1px rgba(0,0,0,0.4);
  transform: scale(1.2);
}

/* ==========================================================================
   Selector de Tamaño Sencillo (🐥 🐱 🐻)
   ========================================================================== */

.size-presets {
  display: flex;
  align-items: center;
  gap: 6px;
}

.size-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.size-btn:hover {
  transform: scale(1.15);
  background: rgba(255, 255, 255, 0.15);
}

.size-btn.active {
  background: #8b5cf6;
  border-color: #c4b5fd;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
  transform: scale(1.15);
}

/* ==========================================================================
   Barra Desplegable de Stickers y Emoticones
   ========================================================================== */

.stickers-drawer {
  position: absolute;
  top: 60px;
  left: 0;
  width: 100%;
  background: rgba(22, 23, 54, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--pink);
  box-shadow: var(--shadow-md);
  padding: 12px 18px;
  z-index: 90;
  display: none;
  flex-direction: column;
  gap: 10px;
  animation: slideDown 0.2s ease-out;
}

.stickers-drawer.open {
  display: flex;
}

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

.stickers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stickers-title {
  font-size: 13px;
  font-weight: 700;
  color: #fde047;
}

.stickers-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.stickers-close-btn:hover {
  color: #fff;
}

.stickers-grid {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px;
  -webkit-overflow-scrolling: touch;
}

.sticker-item {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  font-size: 32px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sticker-item:hover {
  transform: scale(1.22);
  background: rgba(236, 72, 153, 0.25);
  border-color: #ec4899;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
}

.sticker-item:active {
  transform: scale(0.9);
}

/* ==========================================================================
   Estado de Conexión & Badge
   ========================================================================== */

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

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.client-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(236, 72, 153, 0.18);
  border: 1px solid rgba(236, 72, 153, 0.4);
  font-size: 12px;
  font-weight: 800;
  color: #f472b6;
}

/* ==========================================================================
   Viewport y Contenedor del Lienzo
   ========================================================================== */

.canvas-viewport {
  flex: 1;
  width: 100%;
  height: calc(100vh - 58px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 0);
  background-size: 24px 24px;
  position: relative;
}

.canvas-card {
  position: relative;
  background-color: var(--bg-canvas);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 0 0 2px rgba(236, 72, 153, 0.3);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.canvas-container {
  margin: 0 auto !important;
  touch-action: none;
}

.canvas-card.eraser-active {
  cursor: cell;
}

/* ==========================================================================
   Notificaciones Toast
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  background: rgba(30, 27, 75, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.25s ease-out;
  pointer-events: auto;
}

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

.toast-info { border-left: 4px solid var(--blue); }
.toast-success { border-left: 4px solid var(--pink); }
.toast-warning { border-left: 4px solid var(--yellow); }

/* ==========================================================================
   Ajustes Responsivos (Tablets y Pantallas Pequeñas)
   ========================================================================== */

@media (max-width: 900px) {
  .toolbar {
    padding: 6px 10px;
    gap: 6px;
  }
  .rooms-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

@media (max-width: 640px) {
  .rooms-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .divider {
    display: none;
  }
}
