/* ─── Herramientas Morales — Shared Styles ──────────────────────── */
/* Importar desde: <link rel="stylesheet" href="assets/shared.css"> */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

/* ── Design tokens (light) ── */
:root {
  --bg:             #f0f0ed;
  --surface:        #ffffff;
  --surface2:       #f5f5f3;
  --border:         #e2e2de;
  --border-focus:   #aaaaaa;
  --text:           #1a1a1a;
  --text-secondary: #666666;
  --text-muted:     #999999;
  --accent:         #111111;
  --accent-d:       #333333;
  --accent-l:       #f0f0ed;
  --success:        #16a34a;
  --danger:         #dc2626;
  --r:              10px;
  --rs:             8px;
  --shadow-sm:      0 1px 2px rgba(0,0,0,.05), 0 1px 4px rgba(0,0,0,.04);
  --shadow-md:      0 4px 10px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:      0 14px 36px rgba(0,0,0,.11), 0 4px 12px rgba(0,0,0,.06);
  --font:           'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  /* Aliases de compatibilidad */
  --muted:          var(--text-secondary);
  --faint:          var(--text-muted);
  --header-h:       52px;
}

/* ── Dark mode ── */
[data-theme="dark"] {
  --bg:             #1a1a18;
  --surface:        #242422;
  --surface2:       #2e2e2b;
  --border:         #3a3a36;
  --border-focus:   #666660;
  --text:           #f0ede8;
  --text-secondary: #999690;
  --text-muted:     #666660;
  --accent:         #e8e8e4;
  --accent-d:       #cccccc;
  --accent-l:       #2a2a27;
  --shadow-sm:      0 1px 2px rgba(0,0,0,.18), 0 1px 4px rgba(0,0,0,.14);
  --shadow-md:      0 4px 10px rgba(0,0,0,.24), 0 2px 4px rgba(0,0,0,.16);
  --shadow-lg:      0 14px 36px rgba(0,0,0,.32), 0 4px 12px rgba(0,0,0,.18);
}

/* ── Base body ── */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Sync status indicator ── */
.sync-status {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.sync-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ccc;
  flex-shrink: 0;
  transition: background 0.3s;
}
.sync-dot.ok      { background: #4caf50; }
.sync-dot.err     { background: #e53935; }
.sync-dot.loading { background: #fb8c00; animation: hm-pulse 0.8s infinite; }
@keyframes hm-pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Toast ── */
.hm-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--accent);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--rs);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s cubic-bezier(0.34,1.4,0.64,1);
  z-index: 9999;
  max-width: 360px;
  line-height: 1.4;
  box-shadow: var(--shadow-md);
}
.hm-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.hm-toast.error { background: #c62828; }
.hm-toast.success { background: #2e7d32; }

/* ── Dark mode toggle button ── */
.btn-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--rs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-theme-toggle:hover {
  border-color: var(--border-focus);
  color: var(--text);
  background: var(--bg);
}

/* ── Loading overlay for iframes ── */
.iframe-loader {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}
.iframe-loader.visible { opacity: 1; pointer-events: all; }
.iframe-loader .spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: hm-spin 0.75s linear infinite;
}
.iframe-loader p {
  font-size: 12px;
  color: var(--text-muted);
}
@keyframes hm-spin { to { transform: rotate(360deg); } }

/* ── Scrollbar elegante ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }

/* ── Focus visible accesible ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Transition suave de tema ── */
*, *::before, *::after {
  transition-property: background-color, border-color, color;
  transition-duration: 0.15s;
  transition-timing-function: ease;
}
/* Excluir de la transición global elementos con animaciones propias */
.sync-dot, .hm-toast, .iframe-loader, .spinner {
  transition: none;
}
.sync-dot { transition: background 0.3s; }
.hm-toast { transition: opacity 0.22s, transform 0.22s cubic-bezier(0.34,1.4,0.64,1); }

/* ══════════════════════════════════════════════════
   HM-PAGE-HEADER  — cabecera unificada para sub-páginas
   Uso: reemplaza cualquier <header> / .topbar local
   ══════════════════════════════════════════════════ */
.hm-page-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px 0 0;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

/* Botón de vuelta al inicio */
.hm-header-home {
  width: var(--header-h);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.hm-header-home:hover {
  background: var(--bg);
  color: var(--text);
}
.hm-header-home svg { width: 18px; height: 18px; }

/* Título y subtítulo */
.hm-header-info {
  padding-left: 16px;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.hm-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hm-header-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Separador vertical de controles */
.hm-header-sep { flex: 1; }

/* Agrupación derecha de controles */
.hm-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Móvil/tablet estrecho: el grupo de botones ya no cabe fijo junto al
   título — se le permite encoger y, si aun así no entra todo, se
   desplaza en horizontal dentro de su propia franja (igual que las
   barras de filtros/acciones de otras herramientas), en vez de forzar
   scroll horizontal a toda la página. */
@media (max-width: 900px) {
  .hm-header-right {
    flex-shrink: 1;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .hm-header-sub { display: none; }
}

/* ── Contenedor de contenido para sub-páginas ── */
.hm-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.hm-content.hm-content-wide {
  max-width: 1140px;
}
.hm-content.hm-content-narrow {
  max-width: 680px;
}

/* ── Botón primary compartido ── */
.hm-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--rs);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.hm-btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}
.hm-btn-primary:hover { opacity: 0.85; }
.hm-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.hm-btn-ghost:hover {
  background: var(--bg);
  border-color: var(--border-focus);
  color: var(--text);
}

/* ── Card compartida ── */
.hm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

/* ── Label + input compartidos ── */
.hm-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}
.hm-input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  font-size: 13px;
  font-family: var(--font);
  background: var(--surface2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.hm-input:focus {
  border-color: var(--border-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(17,17,17,.06);
}
[data-theme="dark"] .hm-input:focus {
  box-shadow: 0 0 0 3px rgba(232,232,228,.08);
}
.hm-input::placeholder { color: var(--text-muted); }

/* ══ Cabecera estilo ppoma — sub-páginas ══ */
.hm-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.hm-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.hm-header-text h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.hm-header-text p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}
.hm-header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
/* Botón volver al inicio */
.hm-header-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition: all 0.15s;
}
.hm-header-back:hover {
  border-color: var(--border-focus);
  color: var(--text);
  background: var(--bg);
}
.hm-header-back svg { width: 18px; height: 18px; }
/* btn-gear compartido (38×38, estilo ppoma) */
.btn-gear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.btn-gear:hover {
  border-color: var(--border-focus);
  color: var(--text);
  background: var(--bg);
}
.btn-gear svg { width: 18px; height: 18px; }
