/* ============================================
   TEMA GLOBAL - CMS Nugou
   Variables CSS para modo claro y oscuro
   ============================================ */

:root {
  /* === FONDOS === */
  --bg-body: #e6f0ff;
  --bg-card: #ffffff;
  --bg-card-hover: #fdfefe;
  --bg-section: #cce0ff;
  --bg-input: #ffffff;
  --bg-topbar: #ffffff;
  --bg-sidebar: #003366;
  --bg-sidebar-hover: #0059b3;
  --bg-file-icon: #f1f3f5;
  --bg-modal: rgba(0,0,0,0.75);
  --bg-modal-content: #ffffff;
  --bg-badge: #222;
  --bg-code: #f1f1f1;
  --bg-progress: #eee;

  /* === TEXTOS === */
  --text-primary: #003366;
  --text-secondary: #495057;
  --text-muted: #666666;
  --text-heading: #003366;
  --text-on-card: #333333;
  --text-placeholder: #999;
  --text-on-sidebar: #ffffff;
  --text-label: #495057;
  --text-on-dark-badge: #ffffff;

  /* === BORDES === */
  --border-color: #ced4da;
  --border-light: #dee2e6;
  --border-section: #e1e9f5;
  --border-card: #e9ecef;

  /* === SOMBRAS === */
  --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.08);
  --shadow-card-hover: 0 6px 20px rgba(0, 0, 0, 0.12);
  --shadow-topbar: 0 2px 5px rgba(0, 0, 0, 0.1);
  --shadow-sidebar: 2px 0 5px rgba(0, 0, 0, 0.2);

  /* === BOTONES === */
  --btn-primary-bg: #0059b3;
  --btn-primary-hover: #0073e6;
  --btn-secondary-bg: #6c757d;
  --btn-secondary-hover: #5a6268;

  /* === ESTADOS === */
  --success-bg: #d4edda;
  --success-text: #155724;
  --success-border: #c3e6cb;
  --danger-bg: #f8d7da;
  --danger-text: #721c24;
  --danger-border: #f5c6cb;

  /* === COMPONENTES === */
  --clock-bg: #ffffff;
  --clock-border: #dee2e6;
  --clock-text: #495057;
  --filter-bg: #f1f3f5;
  --filter-text: #495057;
  --filter-border: #dee2e6;
  --filter-active-bg: #0059b3;
  --filter-active-text: #ffffff;
  --search-bg: #ffffff;
  --tag-bg: #3498db;

  /* === TRANSICIÓN === */
  --theme-transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease, border 0.5s ease;
}

/* ============================================
   MODO OSCURO
   ============================================ */
[data-theme="dark"] {
  /* === FONDOS === */
  --bg-body: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #1e1e35;
  --bg-section: #16213e;
  --bg-input: #12122a;
  --bg-topbar: #1a1a2e;
  --bg-sidebar: #0a0a1a;
  --bg-sidebar-hover: #1a1a3e;
  --bg-file-icon: #252545;
  --bg-modal: rgba(0,0,0,0.85);
  --bg-modal-content: #1a1a2e;
  --bg-badge: #0f0f23;
  --bg-code: #252545;
  --bg-progress: #252545;

  /* === TEXTOS === */
  --text-primary: #e8e8f0;
  --text-secondary: #b0b0c8;
  --text-muted: #8888a8;
  --text-heading: #e8e8f0;
  --text-on-card: #d0d0e0;
  --text-placeholder: #666688;
  --text-on-sidebar: #c8c8e0;
  --text-label: #b0b0c8;
  --text-on-dark-badge: #e0e0f0;

  /* === BORDES === */
  --border-color: #2a2a4a;
  --border-light: #2a2a4a;
  --border-section: #2a2a4a;
  --border-card: #2a2a4a;

  /* === SOMBRAS === */
  --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.4);
  --shadow-card-hover: 0 6px 20px rgba(0, 0, 0, 0.5);
  --shadow-topbar: 0 2px 5px rgba(0, 0, 0, 0.4);
  --shadow-sidebar: 2px 0 5px rgba(0, 0, 0, 0.5);

  /* === BOTONES === */
  --btn-primary-bg: #0059b3;
  --btn-primary-hover: #0073e6;
  --btn-secondary-bg: #4a4a6a;
  --btn-secondary-hover: #3a3a5a;

  /* === ESTADOS === */
  --success-bg: #1a3a2a;
  --success-text: #6ddb8a;
  --success-border: #2a5a3a;
  --danger-bg: #3a1a1a;
  --danger-text: #e88a8a;
  --danger-border: #5a2a2a;

  /* === COMPONENTES === */
  --clock-bg: #1a1a2e;
  --clock-border: #2a2a4a;
  --clock-text: #b0b0c8;
  --filter-bg: #252545;
  --filter-text: #b0b0c8;
  --filter-border: #2a2a4a;
  --filter-active-bg: #0059b3;
  --filter-active-text: #ffffff;
  --search-bg: #12122a;
  --tag-bg: #2568a8;
}

/* ============================================
   TRANSICIÓN GLOBAL SUAVE
   ============================================ */
*,
*::before,
*::after {
  transition: var(--theme-transition);
}

/* Excluir animaciones de transición en iframes y previews */
iframe,
.preview-scale,
.preview-wrapper {
  transition: none !important;
}

/* ============================================
   BOTÓN TOGGLE DE TEMA (en sidebar)
   ============================================ */
.theme-toggle-sidebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-on-sidebar);
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: Arial, sans-serif;
  transition: background 0.3s ease;
}

.theme-toggle-sidebar:hover {
  background: var(--bg-sidebar-hover);
}

.theme-toggle-sidebar .toggle-icon {
  font-size: 18px;
  display: inline-flex;
  transition: transform 0.5s ease;
}

.theme-toggle-sidebar.switching .toggle-icon,
.theme-toggle-float.switching .toggle-icon {
  animation: toggleSpin 0.5s ease;
}

@keyframes toggleSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================
   BOTÓN FLOTANTE (páginas sin sidebar)
   ============================================ */
.theme-toggle-float {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle-float:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-card-hover);
}

.theme-toggle-float .toggle-icon {
  font-size: 20px;
  display: inline-flex;
}

/* ============================================
   PUNTO DE CONEXIÓN DEL PLAYER (product cards)
   ============================================ */
.conn-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: 1px;
}

.conn-dot.on {
  background: #2ecc71;
  box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.15);
  animation: connBlink 1.4s ease-in-out infinite;
}

.conn-dot.off {
  background: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
  animation: connBlink 1.4s ease-in-out infinite;
}

@keyframes connBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
