/* ====== Variables ====== */
:root {
  --text:        #333333;   /* gris oscuro para el texto */
  --text-soft:   #666666;
  --border:      #e9e9e9;
  --bg:          #ffffff;
  --accent:      #222222;
  --sidebar-w:   260px;
  --topbar-h:    56px;
}

/* ====== Base ====== */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: #000; }

/* ====== Barra superior ====== */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1000;
}

.toggle-sidebar { border: 1px solid var(--border); }

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.3px;
}

.login-area { margin-left: auto; }

.login-form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.login-form input { width: 120px; }

.login-status {
  display: flex;
  align-items: center;
  gap: 10px;
}
.login-status .user-name { font-size: .9rem; color: var(--text-soft); }

/* ====== Layout 2 columnas ====== */
.layout {
  display: flex;
  flex: 1; 
}

/* ---- Columna izquierda ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  transition: margin-left .25s ease, opacity .2s ease;
}

/* Estado colapsado */
.layout.collapsed .sidebar {
  margin-left: calc(-1 * var(--sidebar-w));
  opacity: 0;
}

.profile { text-align: center; margin-bottom: 22px; }
.profile-img {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.menu li { margin-bottom: 4px; }

.menu-link {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  transition: background .15s;
}
.menu-link i { margin-right: 8px; color: var(--text-soft); }
.menu-link:hover { background: #f5f5f5; }
.menu-link.active { background: #efefef; font-weight: 600; }

.menu hr { border-color: var(--border); margin: 16px 0; }
.menu-secondary .menu-link { font-size: .9rem; color: var(--text-soft); }

/* ---- Columna derecha ---- */
.content {
  flex: 1;
  padding: 36px 48px;
  max-width: 820px;   /* foco en la lectura */
  margin: 0 auto;
  width: 100%;
}

.page-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.lead-text { color: var(--text-soft); margin-bottom: 30px; }

/* ====== Widgets ====== */
.widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.widget {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  background: #fff;
}
.widget:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  transform: translateY(-2px);
}
.widget .w-label { font-size: .8rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .5px; }
.widget .w-value { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }
.widget .w-change { font-size: .85rem; margin-top: 2px; }
.w-up   { color: #1a7f37; }
.w-down { color: #b42318; }

/* ====== Lista de posts ====== */
.post-list { margin-top: 10px; }

.post-item {
  padding: 18px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.post-item:hover .post-title { text-decoration: underline; }
.post-title { font-size: 1.25rem; font-weight: 600; margin: 0 0 4px; }
.post-excerpt { color: var(--text-soft); font-size: .95rem; }

/* ====== Artículo ====== */
.back-btn { margin-bottom: 20px; border: 1px solid var(--border); }
.article { font-size: 1.05rem; }
.article h1, .article h2, .article h3 { letter-spacing: -0.3px; }
.article img { max-width: 100%; height: auto; border-radius: 8px; }
.article p { margin-bottom: 1.1em; }

/* ====== Paginación ====== */
.pager {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 26px;
}
.pager button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.pager button.active { background: var(--accent); color: #fff; }
.pager button:disabled { opacity: .4; cursor: default; }

/* ====== Popup ====== */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.popup {
  background: #fff;
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  padding: 26px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.popup-close {
  position: absolute;
  top: 12px; right: 12px;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-soft);
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
  .content { padding: 24px 18px; }
  .login-form input { width: 90px; }

  /* En móvil la sidebar se superpone */
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    height: calc(100vh - var(--topbar-h));
    background: #fff;
    z-index: 900;
    box-shadow: 2px 0 12px rgba(0,0,0,.08);
  }
  .layout.collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
}

/* Utilidad */
.d-none { display: none !important; }

.article-head { margin-bottom: 4px; }
.article-body { color: var(--text); }
.article-body p { margin-bottom: 1.1em; }
.article-body img { max-width: 100%; height: auto; border-radius: 8px; }

/* ====== Estructura para footer pegado abajo ====== */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.layout {
  flex: 1;            /* empuja el footer hacia abajo */
}

/* ====== Pie de página ====== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: .85rem;
  color: var(--text-soft);
  background: var(--bg);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
}

.footer-link {
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .15s;
}
.footer-link:hover { color: #000; }
.footer-link i { color: var(--text-soft); }

/* El botón de cookies con apariencia de enlace */
.footer-link--btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.footer-platform a {
  color: var(--text);
  font-weight: 600;
}
.footer-platform a:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 18px;
  }
}

/* ====== Páginas legales ====== */
.article .legal-updated {
  color: var(--text-soft);
  font-size: .85rem;
  margin-bottom: 24px;
}
.article h2 {
  font-size: 1.25rem;
  margin-top: 28px;
  margin-bottom: 8px;
}
.article ul {
  padding-left: 20px;
  margin-bottom: 1.1em;
}
.article ul li { margin-bottom: 6px; }

/* ====== Imágenes dentro de las stories ====== */
.article img {
  display: block;       /* necesario para poder centrar con margin auto */
  max-width: 70%;       /* nunca más del 80% del ancho disponible */
  height: auto;         /* mantiene la proporción */
  margin: 24px auto;    /* centrada horizontalmente + aire arriba/abajo */
  border-radius: 8px;
}

/* Si usas <figure> con pie de foto */
.article figure {
  margin: 24px auto;
  text-align: center;
}
.article figure img {
  margin: 0 auto 8px;   /* la imagen ya va dentro del figure */
}
.article figcaption {
  font-size: .85rem;
  color: var(--text-soft);
}
