/* =========================================================================
   GoodNews Tools — Sistema de diseño (estilo Apple, paleta GoodNews en claro)
   Limpio, sobrio, mucho aire. Casi-blanco cálido como lienzo; verde de ACENTO.
   ========================================================================= */
:root {
  --bg:        #FAF9F6;   /* casi-blanco cálido (lienzo) */
  --surface:   #FFFFFF;
  --hairline:  #E9E5DD;   /* línea fina cálida */
  --ink:       #1D1D1F;   /* texto principal */
  --ink-2:     #6E6B66;   /* texto secundario */
  --green:     #57745B;   /* acento de marca */
  --green-deep:#425A46;   /* hover / texto-acento */
  --green-050: #F1F4EF;   /* tinte muy claro (badges/hover) */
  --green-100: #E6ECE4;

  --radius-sm: 8px;  --radius-md: 14px;  --radius-lg: 20px;  --radius-pill: 980px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --shadow-lift: 0 6px 24px rgba(29,29,31,.08);
  --ease: cubic-bezier(0.4, 0.0, 0.2, 1);
  --dur: 280ms;
  --container-max: 1080px;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.011em;
}

a { color: var(--green-deep); text-decoration: none; }
a:hover { color: var(--green); }

h1, h2, h3 { line-height: 1.08; letter-spacing: -0.025em; margin: 0; font-weight: 600; color: var(--ink); }

/* ---------- Cabecera (clara, translúcida, estilo Apple) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(233,241,231,.82);   /* verde MUY claro translúcido */
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid #dde6da;
  color: var(--ink);
  padding: .55rem 1.5rem;
  display: flex; align-items: center; gap: 1.25rem;
}
.topbar .brand {
  color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .55rem;
}
.topbar .brand-icon { height: 30px; width: 30px; border-radius: 50%; }
.brand-word { display: inline-flex; flex-direction: column; line-height: .98; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.03em; }
.brand-word2 { font-weight: 500; font-size: .82rem; letter-spacing: -0.01em; color: var(--green-deep); }
.topbar nav { display: flex; gap: .35rem; margin-left: .75rem; flex-wrap: wrap; }
.topbar nav a {
  color: var(--ink-2); text-decoration: none; padding: .35rem .6rem; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 450; transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.topbar nav a:hover { color: var(--ink); background: rgba(0,0,0,.035); }
.topbar .spacer { flex: 1; }

/* ---------- Selector de idioma ---------- */
.lang-switch { display: inline-flex; gap: .1rem; }
.topbar .lang-switch a { color: var(--ink-2); padding: .2rem .45rem; border-radius: var(--radius-sm); font-size: .78rem; font-weight: 500; }
.topbar .lang-switch a.active { color: var(--green-deep); font-weight: 700; }

/* ---------- Menú de usuario (desplegable) ---------- */
.usermenu { position: relative; }
.usermenu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
  padding: .25rem .55rem; border-radius: var(--radius-md);
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: rgba(0,0,0,.04); }
.um-id { display: flex; flex-direction: column; line-height: 1.1; text-align: right; }
.um-id .um-name { font-size: .9rem; font-weight: 600; color: var(--ink); }
.um-id .um-type { font-size: .74rem; font-weight: 400; color: var(--ink-2); }
.um-caret { color: var(--ink-2); font-size: .7rem; }
.um-panel {
  position: absolute; right: 0; top: calc(100% + .5rem); min-width: 240px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift); padding: .4rem; z-index: 200;
}
.um-head { padding: .6rem .7rem .7rem; border-bottom: 1px solid var(--hairline); margin-bottom: .35rem; }
.um-head .um-name { font-weight: 600; font-size: .95rem; }
.um-head .um-email { font-size: .8rem; color: var(--ink-2); }
.um-item { display: block; padding: .55rem .7rem; border-radius: var(--radius-sm); color: var(--ink); font-size: .9rem; text-decoration: none; }
.um-item:hover { background: var(--green-050); color: var(--ink); }
.um-danger { color: #8a3b2f; }
.um-danger:hover { background: #fbf0ee; color: #8a3b2f; }

/* ---------- Contenedor / ritmo ---------- */
.container { max-width: var(--container-max); margin: 0 auto; padding: 4.5rem 1.5rem 3rem; }
@media (min-width: 900px) { .container { padding: 6rem 2rem 4rem; } }
.page-title { font-size: clamp(2rem, 1.4rem + 3vw, 3rem); margin: 0 0 .6rem; }
.subtle { color: var(--ink-2); font-size: 1.05rem; }

/* ---------- Tarjetas de módulos ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; margin-top: 2.25rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
  display: block;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: #ded9cf; }
.card-cover {
  position: relative; height: 150px; background: var(--green-100);
  display: flex; align-items: center; justify-content: center;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-lock {
  position: absolute; top: .7rem; right: .7rem;
  background: rgba(29,29,31,.62); color: #fff; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  font-size: .72rem; font-weight: 600; padding: .25rem .65rem; border-radius: var(--radius-pill);
}
.card-locked .card-cover img { filter: grayscale(.55) brightness(.97); }
.card-body { padding: 1.4rem 1.6rem 1.7rem; }
.card-body h3 { margin: 0 0 .35rem; font-size: 1.2rem; }
.card-body p { margin: 0; color: var(--ink-2); font-size: .95rem; line-height: 1.5; }
.card .role { display: inline-block; margin-top: 1.1rem; font-size: .8rem; font-weight: 500; color: var(--ink-2); }
.role-locked { color: var(--green-deep); font-weight: 600; }

/* ---------- Login ---------- */
.login-wrap { min-height: 88vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem; }
.login-card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-lg); box-shadow: var(--shadow-lift); padding: 3.25rem 2.75rem; max-width: 420px; width: 100%; text-align: center; }
.login-card .login-logo { max-width: 200px; width: 70%; height: auto; margin: 0 auto .75rem; display: block; }
.login-card .brand-sub { font-weight: 600; color: var(--ink); margin: .5rem 0 0; font-size: 1.15rem; letter-spacing: -0.02em; }
.login-card p { color: var(--ink-2); margin: .35rem 0 1.9rem; }
.login-lang { margin-top: 1.75rem; }
.login-lang a { color: var(--ink-2); padding: .1rem .4rem; font-size: .8rem; font-weight: 500; }
.login-lang a.active { color: var(--green-deep); font-weight: 700; }

/* ---------- Botones (píldora, acento) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--green); color: #fff; border: none; border-radius: var(--radius-pill);
  padding: .72rem 1.5rem; font-size: .98rem; font-weight: 500; font-family: inherit;
  cursor: pointer; text-decoration: none; letter-spacing: -0.01em;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--green-deep); color: #fff; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--green-deep); border: 1px solid var(--hairline); }
.btn-ghost:hover { background: var(--green-050); color: var(--green-deep); }

/* ---------- Tablas ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-md); overflow: hidden; }
th, td { text-align: left; padding: .85rem 1rem; border-bottom: 1px solid var(--hairline); }
th { background: #fbfaf7; color: var(--ink-2); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }

select, input[type="text"], input[type="email"] {
  padding: .55rem .7rem; border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  font-size: .95rem; background: var(--surface); color: var(--ink); font-family: inherit;
}
select:focus, input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-050); }

/* ---------- Avisos ---------- */
.alert { padding: 1rem 1.2rem; border-radius: var(--radius-md); margin-bottom: 1rem; border: 1px solid var(--hairline); background: var(--green-050); color: var(--green-deep); font-size: .95rem; }
.alert-error { background: #fbf0ee; border-color: #efd9d4; color: #8a3b2f; }

/* ---------- Mi cuenta ---------- */
.account-dl { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 0; }
.account-dl dt { color: var(--ink-2); font-size: .9rem; }
.account-dl dd { margin: 0; font-weight: 500; }

/* ---------- Pie ---------- */
.footer { text-align: center; color: var(--ink-2); font-size: .8rem; padding: 4rem 1.5rem 3rem; }
.footer-watermark { display: block; max-width: 84px; height: auto; margin: 0 auto .6rem; opacity: .45; }

/* ---------- Overlay de carga global ---------- */
.app-loading {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(250,249,246,.6); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
.app-loading[hidden] { display: none; }
.app-loading-box { background: #fff; border: 1px solid var(--hairline); border-radius: var(--radius-md); padding: 1.25rem 1.5rem; box-shadow: var(--shadow-lift); }
.app-loading-spinner { width: 34px; height: 34px; border: 3px solid var(--green-100); border-top-color: var(--green); border-radius: 50%; animation: app-spin .8s linear infinite; }
@keyframes app-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { *:not(.app-loading-spinner):not(.busy-spinner) { transition: none !important; animation: none !important; } }
