/* ── Variables ─────────────────────────────────────────────── */
:root {
  --color-bg: #ffffff;
  --color-surface: #f7fbfe;
  --color-border: #e9ecef;
  --color-text: #444444;
  --color-text-muted: #6c757d;
  --color-heading: #222222;
  --color-primary: #3498db;
  --color-primary-hover: #57aae1;
  /* Disciplinas: sólido = insignia sobre blanco; claro = acento sobre fondo oscuro */
  --d-psicologia: #0c7a6d;
  --d-psicologia-claro: #2fb8a4;
  --d-filosofia: #6f55c8;
  --d-filosofia-claro: #9b86f2;
  --d-ciencia: #1f78b4;
  --d-ciencia-claro: #57aae1;
  --d-tecnologia: #5f7181;
  --d-tecnologia-claro: #a3b3c2;
  --color-danger: #dc3545;
  --color-danger-hover: #bb2d3b;
  --color-success: #198754;
  --font-sans: 'Open Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Raleway', var(--font-sans);
  --font-mono: 'Fira Code', 'Cascadia Code', monospace;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --max-width: 760px;
  --max-width-wide: 1100px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
}
img { max-width: 100%; display: block; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ───────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  padding: .9rem 1.5rem;
}
.nav-inner {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -.02em;
}
.nav-brand:hover { text-decoration: none; color: var(--color-primary); }
.nav-links { display: flex; gap: 1rem; margin-left: auto; align-items: center; }
.nav-links a { font-size: .9rem; color: var(--color-text-muted); }
.nav-links a:hover { color: var(--color-primary); text-decoration: none; }

/* ── Layout containers ─────────────────────────────────────── */
.container {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.container-narrow {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.page { padding: 3rem 0; }

/* ── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.3; font-weight: 700; letter-spacing: -.02em; color: var(--color-heading); }
h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.25rem; }
p + p { margin-top: 1rem; }

/* ── Post list ─────────────────────────────────────────────── */
.post-list { list-style: none; display: flex; flex-direction: column; gap: 1.5rem; }
.post-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: var(--color-bg);
  transition: box-shadow .2s, border-color .2s;
}
.post-card:hover { box-shadow: var(--shadow-md); border-color: #cbd5e1; }
.post-card-title { font-size: 1.2rem; margin-bottom: .4rem; }
.post-card-title a { color: var(--color-text); }
.post-card-title a:hover { color: var(--color-primary); text-decoration: none; }
.post-card-meta { font-size: .82rem; color: var(--color-text-muted); margin-bottom: .6rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.post-card-excerpt { color: var(--color-text-muted); font-size: .95rem; }

/* ── Tags / Categories ─────────────────────────────────────── */
.tag {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .2rem .6rem;
  border-radius: 999px;
  background: #e7f0ff;
  color: var(--color-primary);
  cursor: pointer;
}
.tag:hover { background: var(--color-primary); color: #fff; text-decoration: none; }
.tag-filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 2rem; }

/* ── Single post ───────────────────────────────────────────── */
.post-layout { display: grid; grid-template-columns: 1fr 220px; gap: 3rem; align-items: start; }
@media (max-width: 768px) { .post-layout { grid-template-columns: 1fr; } }

.post-header { margin-bottom: 2rem; }
.post-header h1 { margin-bottom: .75rem; }
.post-meta { font-size: .85rem; color: var(--color-text-muted); display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }

.post-content { font-size: 1.05rem; }
.post-content h2 { margin: 2rem 0 .75rem; padding-top: 1rem; border-top: 1px solid var(--color-border); }
.post-content h3 { margin: 1.5rem 0 .5rem; }
.post-content p { margin-bottom: 1rem; }
.post-content ul, .post-content ol { margin: 1rem 0 1rem 1.5rem; }
.post-content li { margin-bottom: .3rem; }
.post-content blockquote { border-left: 3px solid var(--color-primary); padding: .5rem 1rem; margin: 1.5rem 0; background: var(--color-surface); border-radius: 0 var(--radius) var(--radius) 0; color: var(--color-text-muted); }
.post-content code { font-family: var(--font-mono); font-size: .88em; background: var(--color-surface); padding: .15em .4em; border-radius: 4px; }
.post-content pre { background: #1e293b; color: #e2e8f0; padding: 1.2rem; border-radius: var(--radius); overflow-x: auto; margin: 1.5rem 0; }
.post-content pre code { background: none; padding: 0; color: inherit; font-size: .9em; }
.post-content a { text-decoration: underline; }
.post-content img { border-radius: var(--radius); margin: 1.5rem 0; }

/* ── TOC (table of contents) ───────────────────────────────── */
.toc {
  position: sticky;
  top: 5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: .88rem;
}
.toc-title { font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); margin-bottom: .75rem; }
.toc ul { list-style: none; display: flex; flex-direction: column; gap: .3rem; }
.toc a { color: var(--color-text-muted); line-height: 1.4; }
.toc a:hover { color: var(--color-primary); text-decoration: none; }
.toc a.active { color: var(--color-primary); font-weight: 600; }
.toc-h3 { padding-left: .9rem; font-size: .84rem; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  font-size: .9rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  line-height: 1;
  text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-hover); }
.btn-ghost { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }
.btn-ghost:hover { background: var(--color-surface); color: var(--color-text); }
.btn-sm { padding: .35rem .75rem; font-size: .82rem; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .4rem; color: var(--color-text); }
input[type="text"], input[type="password"], input[type="date"], input[type="datetime-local"], textarea, select {
  width: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(52,152,219,.2);
}
textarea { resize: vertical; min-height: 120px; }

/* ── Tags input ────────────────────────────────────────────── */
.tags-input-wrapper {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .4rem .6rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  cursor: text;
  background: var(--color-bg);
  min-height: 2.6rem;
  align-items: center;
}
.tags-input-wrapper:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(52,152,219,.2); }
.tags-input-wrapper .tag { cursor: default; }
.tags-input-wrapper .tag-remove { margin-left: .3rem; cursor: pointer; opacity: .7; }
.tags-input-wrapper .tag-remove:hover { opacity: 1; }
.tags-input-field { border: none; outline: none; font-size: .9rem; flex: 1; min-width: 120px; font-family: inherit; background: transparent; }

/* ── Admin layout ──────────────────────────────────────────── */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: .85rem 1rem; text-align: left; border-bottom: 1px solid var(--color-border); font-size: .9rem; }
.admin-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); font-weight: 600; }
.admin-table tr:hover td { background: var(--color-surface); }
.admin-table .actions { display: flex; gap: .5rem; }

/* ── Login ─────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--color-surface); }
.login-card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.login-card h1 { font-size: 1.5rem; margin-bottom: .4rem; }
.login-card .subtitle { color: var(--color-text-muted); font-size: .9rem; margin-bottom: 2rem; }

/* ── Alert ─────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .9rem; margin-bottom: 1rem; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* ── Editor (EasyMDE override) ─────────────────────────────── */
.EasyMDEContainer .CodeMirror { border-radius: 0 0 var(--radius) var(--radius); font-family: var(--font-mono); font-size: .92rem; }
.editor-toolbar { border-radius: var(--radius) var(--radius) 0 0; }

/* ── Empty state ───────────────────────────────────────────── */
.empty { text-align: center; padding: 4rem 1rem; color: var(--color-text-muted); }
.empty h3 { margin-bottom: .5rem; }

/* ── Pagination ────────────────────────────────────────────── */
.pagination { display: flex; gap: .5rem; justify-content: center; margin-top: 3rem; flex-wrap: wrap; }
.pagination button { padding: .5rem .9rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-bg); cursor: pointer; font-size: .9rem; }
.pagination button.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination button:hover:not(.active) { background: var(--color-surface); }

/* ── Footer ────────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--color-border); padding: 2rem 1.5rem; text-align: center; font-size: .85rem; color: var(--color-text-muted); margin-top: 4rem; }
.footer a { color: var(--color-text-muted); }
.footer a:hover { color: var(--color-primary); }

/* ── Site footer (Pensatu-style) ───────────────────────────── */
.site-footer { background: var(--color-heading); color: #ccc; padding: 2rem 1.5rem; margin-top: 4rem; font-size: .9rem; text-align: center; }
.site-footer .footer-inner { max-width: var(--max-width-wide); margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; }
.site-footer .copyright { color: #ddd; }
.site-footer .copyright strong { color: #fff; }
.site-footer .footer-links { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.site-footer .footer-links a { color: #ccc; font-size: .85rem; }
.site-footer .footer-links a:hover { color: var(--color-primary); text-decoration: none; }

/* ── Site nav (Pensatu-style) ───────────────────────────────── */
.nav-links a.is-active { color: var(--color-primary); font-weight: 600; }

/* ── Spinner ───────────────────────────────────────────────── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav-inner { gap: 1rem; }
  .page { padding: 2rem 0; }
  .admin-table th:nth-child(3), .admin-table td:nth-child(3) { display: none; }
}

/* Ayuda bajo un campo de formulario */
.form-hint { display: block; margin-top: .35rem; font-size: .8rem; color: var(--color-text-muted); }

/* ── Disciplina (psicología/filosofía a un lado, ciencia/tecnología al otro) ── */
.discipline-badge {
  display: inline-block;
  margin-bottom: .6rem;
  padding: .1rem .7rem .15rem;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #fff;
  background: var(--discipline-color, var(--color-primary));
}
.discipline-badge:hover { text-decoration: none; filter: brightness(1.1); }
.discipline-badge[data-discipline="psicologia"] { --discipline-color: var(--d-psicologia); }
.discipline-badge[data-discipline="filosofia"]  { --discipline-color: var(--d-filosofia); }
.discipline-badge[data-discipline="ciencia"]    { --discipline-color: var(--d-ciencia); }
.discipline-badge[data-discipline="tecnologia"] { --discipline-color: var(--d-tecnologia); }
.clear-filter { display: inline-block; margin: -1.5rem 0 2rem; font-size: .85rem; }

/* ── Etiqueta activa en el filtro del archivo ──────────────── */
.tag.is-selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.tag.is-selected:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

/* ── Utilidades ────────────────────────────────────────────── */
/* Sin !important: el JS que asigna un display concreto sigue mandando */
.u-hidden { display: none; }
.u-center { text-align: center; }
.u-center-mt { text-align: center; margin-top: 2rem; }
.u-mb-2 { margin-bottom: 2rem; }
.u-full { width: 100%; }
.state-box { text-align: center; padding: 3rem 0; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }
