/* ========================================
   AZKORRI · PANEL DE GESTIÓN
   Identidad visual heredada del frontend público
   ======================================== */

:root {
  --primary: #1e2f8c;
  --primary-soft: #eaedfa;
  --primary-hover: #15226b;
  --accent: #d6007c;
  --accent-soft: #fde6f1;
  --accent-hover: #aa0061;
  --cyan: #00a0dc;
  --cyan-soft: #e1f5fc;
  --orange: #f08c00;
  --orange-soft: #fef2dd;
  --yellow: #f0cc00;
  --yellow-soft: #fefae0;
  --green: #2f9e44;
  --green-soft: #e3fbe6;
  --red: #d23131;
  --red-soft: #fde7e7;

  --bg: #f5f7fc;
  --surface: #ffffff;
  --surface-2: #f9fafd;
  --surface-offset: #eef1f8;
  --divider: #e4e8f1;
  --border: #d9dee9;

  --text: #0f1e54;
  --text-muted: #5b6480;
  --text-faint: #9098ad;

  --shadow-sm: 0 1px 2px rgba(15, 30, 84, 0.04), 0 1px 3px rgba(15, 30, 84, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 30, 84, 0.06), 0 2px 4px rgba(15, 30, 84, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 30, 84, 0.08), 0 4px 8px rgba(15, 30, 84, 0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;

  --font-display: 'Clash Display', system-ui, sans-serif;
  --font-body: 'General Sans', system-ui, -apple-system, sans-serif;

  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-w: 256px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

/* ============ LAYOUT GLOBAL ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  background: linear-gradient(180deg, #0f1e54 0%, #1e2f8c 100%);
  color: white;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 20px;
}
.sidebar__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  display: block;
  letter-spacing: -0.01em;
}
.sidebar__subtitle {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.55);
  margin-top: 4px;
}
.sidebar__nav { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar__section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  padding: 16px 12px 6px;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.78);
  font-weight: 500;
  font-size: 14px;
  transition: all var(--transition);
  position: relative;
}
.sidebar__link svg { flex-shrink: 0; opacity: 0.8; }
.sidebar__link:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}
.sidebar__link.is-active {
  background: rgba(214, 0, 124, 0.18);
  color: white;
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}
.sidebar__link.is-active svg { opacity: 1; color: var(--accent); }

.sidebar__footer {
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 16px;
}
.sidebar__website {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  transition: all var(--transition);
}
.sidebar__website:hover { background: rgba(255,255,255,0.14); color: white; }

/* ============ MAIN AREA ============ */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ============ TOPBAR ============ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__left { min-width: 0; }
.topbar__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.topbar__subtitle { font-size: 13px; color: var(--text-muted); margin: 2px 0 0; }

.topbar__right { display: flex; align-items: center; gap: 16px; }
.topbar__search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius-full);
  min-width: 260px;
  color: var(--text-faint);
  transition: all var(--transition);
}
.topbar__search:focus-within { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
.topbar__search input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  flex-grow: 1;
  font-size: 13.5px;
}

.topbar__notif {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: all var(--transition);
}
.topbar__notif:hover { background: var(--surface-offset); color: var(--text); }
.topbar__notif-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--accent);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius-full);
}
.topbar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-family: var(--font-display);
}
.topbar__user-info { display: flex; flex-direction: column; line-height: 1.25; }
.topbar__user-info strong { font-size: 13.5px; font-weight: 600; }
.topbar__role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.role-admin { color: var(--accent); }
.role-editor { color: var(--cyan); }
.role-familia { color: var(--orange); }
.topbar__logout button {
  background: none;
  border: none;
  color: var(--text-faint);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: all var(--transition);
}
.topbar__logout button:hover { background: var(--red-soft); color: var(--red); }

/* ============ CONTENT ============ */
.content {
  padding: 32px;
  flex-grow: 1;
}

/* ============ STAT CARDS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card__icon {
  position: absolute;
  top: 20px; right: 20px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
}
.stat-card__icon--primary { background: var(--primary-soft); color: var(--primary); }
.stat-card__icon--accent { background: var(--accent-soft); color: var(--accent); }
.stat-card__icon--cyan { background: var(--cyan-soft); color: var(--cyan); }
.stat-card__icon--orange { background: var(--orange-soft); color: var(--orange); }
.stat-card__icon--green { background: var(--green-soft); color: var(--green); }
.stat-card__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.stat-card__value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.stat-card__delta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}
.stat-card__delta--down { color: var(--red); }

/* ============ DASHBOARD GRID ============ */
.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

/* ============ PANEL ============ */
.panel {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel__head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.panel__title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.panel__body { padding: 0; }
.panel__body--p { padding: 20px 22px; }

/* ============ BUTTON ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13.5px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn--accent { background: var(--accent); }
.btn--accent:hover { background: var(--accent-hover); }
.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); transform: none; }
.btn--danger { background: var(--red); }
.btn--danger:hover { background: #a32525; }
.btn--sm { padding: 6px 12px; font-size: 12.5px; }
.btn--icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--divider);
}
.btn--icon:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table thead th {
  background: var(--surface-2);
  text-align: left;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--divider);
}
.table tbody td {
  padding: 14px 22px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table__title { font-weight: 600; color: var(--text); }
.table__actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============ BADGE ============ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge--published { background: var(--green-soft); color: var(--green); }
.badge--draft { background: var(--orange-soft); color: var(--orange); }
.badge--reunion { background: var(--accent-soft); color: var(--accent); }
.badge--evento { background: var(--cyan-soft); color: var(--cyan); }
.badge--salida { background: var(--orange-soft); color: var(--orange); }
.badge--festivo { background: var(--yellow-soft); color: #a17500; }
.badge--examenes { background: var(--accent-soft); color: var(--accent); }

/* ============ FORM ============ */
.form { display: flex; flex-direction: column; gap: 18px; }
.form__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form__field { display: flex; flex-direction: column; gap: 6px; }
.form__label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.form__help {
  font-size: 12px;
  color: var(--text-faint);
}
.form__input,
.form__select,
.form__textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: var(--surface);
  font-size: 14px;
  transition: all var(--transition);
}
.form__input:focus,
.form__select:focus,
.form__textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form__textarea { min-height: 120px; resize: vertical; font-family: inherit; line-height: 1.55; }
.form__actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--divider); }

/* ============ MENÚ COMEDOR EDITOR ============ */
.menu-week {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
@media (max-width: 900px) { .menu-week { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .menu-week { grid-template-columns: 1fr; } }
.menu-day {
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-day__head {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--divider);
}
.menu-day input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  background: var(--surface);
}
.menu-day input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.menu-day__small { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }

/* ============ ACTIVITY ITEM ============ */
.activity {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.activity__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--divider);
}
.activity__item:last-child { border-bottom: none; }
.activity__icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}
.activity__icon--created { background: var(--green-soft); color: var(--green); }
.activity__icon--updated { background: var(--cyan-soft); color: var(--cyan); }
.activity__icon--deleted { background: var(--red-soft); color: var(--red); }
.activity__text { flex-grow: 1; font-size: 13.5px; line-height: 1.4; }
.activity__text strong { font-weight: 600; }
.activity__time { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

/* ============ EMPTY STATE ============ */
.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-faint);
}
.empty svg { opacity: 0.4; margin-bottom: 12px; }
.empty h3 { font-family: var(--font-display); font-weight: 600; color: var(--text); margin: 0 0 6px; }
.empty p { margin: 0 0 16px; font-size: 13.5px; }

/* ============ LOGIN ============ */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f1e54 0%, #1e2f8c 60%, #d6007c 130%);
  padding: 20px;
}
.login__card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px;
  width: 100%;
  max-width: 440px;
}
.login__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.login__brand-text { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.login__brand-text small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); margin-top: 2px; font-weight: 600; font-family: var(--font-body); }
.login__title { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; }
.login__lead { color: var(--text-muted); margin: 0 0 24px; font-size: 14.5px; }

.login__google {
  width: 100%;
  background: white;
  color: #1f1f1f;
  border: 1.5px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
  transition: all var(--transition);
}
.login__google:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.login__divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
.login__divider::before, .login__divider::after { content: ''; flex-grow: 1; height: 1px; background: var(--divider); }

.login__demo-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 0 0 10px; }
.login__demo-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.login__demo-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  width: 100%;
  text-align: left;
  transition: all var(--transition);
}
.login__demo-btn:hover { background: var(--surface); border-color: var(--primary); box-shadow: var(--shadow-sm); }
.login__demo-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  flex-shrink: 0;
}
.login__demo-info { flex-grow: 1; }
.login__demo-info strong { display: block; font-size: 13.5px; font-weight: 600; }
.login__demo-info span { display: block; font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.login__demo-info .role-chip { display: inline-block; margin-top: 4px; font-size: 10px; padding: 2px 8px; border-radius: var(--radius-full); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.login__demo-info .role-chip.role-admin { background: var(--accent-soft); color: var(--accent); }
.login__demo-info .role-chip.role-editor { background: var(--cyan-soft); color: var(--cyan); }
.login__demo-info .role-chip.role-familia { background: var(--orange-soft); color: var(--orange); }

.login__footer { font-size: 12px; color: var(--text-faint); text-align: center; margin: 0; }
.login__error { background: var(--red-soft); color: var(--red); padding: 10px 14px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 16px; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-left: 4px solid var(--green);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
  font-weight: 500;
  z-index: 100;
  animation: slidein 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slidein {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left var(--transition); width: var(--sidebar-w); }
  .sidebar.is-open { left: 0; }
  .topbar__search { display: none; }
  .content { padding: 20px; }
}
