@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  /* ── Fondos cálidos: lino, crema, arena ── */
  --bg:        #f5f0e8;   /* crema lino — fondo principal */
  --bg2:       #ede6d9;   /* arena suave — tarjetas / nav */
  --bg3:       #e4dace;   /* arena más profunda — inputs / filas hover */
  --border:    rgba(160,130,90,0.18);
  --border2:   rgba(160,130,90,0.32);

  /* ── Textos legibles ── */
  --text:      #2e2318;   /* café oscuro rico */
  --muted:     #8a7560;   /* café medio — labels, íconos, placeholders */

  /* ── Acento: ámbar cálido y oro tostado ── */
  --accent:    #b07d3a;   /* ámbar/caoba — botones, highlights */
  --accent2:   #c99446;   /* oro cálido — hover, detalles */

  /* ── Estado ── */
  --danger:    #c0503c;
  --success:   #4e8c5e;
  --radius:    10px;
  --radius-lg: 16px;
}

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

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ─── SCREEN SYSTEM ─── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ─── LOGIN ─── */
#s-login {
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(176,125,58,0.13) 0%, transparent 70%);
}

.login-box {
  width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2.5rem 2rem;
  animation: fadeUp 0.4s ease;
  box-shadow: 0 4px 28px rgba(80,50,10,0.10);
}

.login-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  color: var(--accent);
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2rem;
}

.field { margin-bottom: 1.1rem; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field select option { background: var(--bg2); color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-gold {
  background: var(--accent);
  color: #faf5ec;
  width: 100%;
  padding: 11px;
  font-size: 15px;
}
.btn-gold:hover { background: var(--accent2); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--muted);
}
.btn-sm:hover { border-color: var(--accent); color: var(--text); }

.btn-danger {
  background: transparent;
  border: 1px solid rgba(192,80,60,0.3);
  color: var(--danger);
  font-size: 12px;
  padding: 4px 10px;
}
.btn-danger:hover { background: rgba(192,80,60,0.09); }

.error-msg {
  font-size: 12px;
  color: var(--danger);
  margin-bottom: 0.75rem;
  display: none;
}

/* ─── TOP NAV ─── */
.top-nav {
  display: flex;
  align-items: center;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border2);
  background: var(--bg2);
  gap: 1rem;
  flex-shrink: 0;
  box-shadow: 0 1px 6px rgba(80,50,10,0.07);
}

.nav-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  color: var(--accent);
  flex: 1;
}

.nav-user { font-size: 13px; color: var(--muted); }
.nav-user strong { color: var(--text); font-weight: 500; }

/* ─── YEAR VIEW ─── */
#s-year { padding: 1.5rem; }

.year-heading {
  font-family: 'DM Serif Display', serif;
  font-size: 56px;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 1.5rem;
  opacity: 0.9;
}

.months-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  flex: 1;
}

.month-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  animation: fadeUp 0.35s ease both;
}
.month-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(80,50,10,0.10);
}
.month-card.current-month { border-color: rgba(176,125,58,0.45); }

.month-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

/* ─── MINI CALENDAR ─── */
.mini-cal { width: 100%; }
.mini-dow-row, .mini-days-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}
.mini-dow-row { margin-bottom: 3px; }
.mini-dow { font-size: 9px; color: var(--muted); text-align: center; font-weight: 500; }
.mini-day {
  font-size: 9px;
  text-align: center;
  padding: 2px 0;
  color: var(--muted);
  border-radius: 3px;
  line-height: 1.4;
}
.mini-day.today { background: var(--accent); color: #faf5ec; font-weight: 700; }
.mini-day.has-note { background: rgba(176,125,58,0.18); color: var(--accent2); }
.mini-day.empty { visibility: hidden; }

/* ─── MONTH VIEW ─── */
#s-month { padding: 1.2rem 1.5rem; }

.month-view-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.month-view-title {
  font-family: 'DM Serif Display', serif;
  font-size: 32px;
  color: var(--text);
  flex: 1;
}
.month-view-title span { color: var(--accent); }

.month-nav-btn {
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: var(--radius);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px;
  transition: all 0.15s;
}
.month-nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.full-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  flex: 1;
}

.full-dow {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); text-align: center;
  padding: 6px 0 4px;
}

.day-cell {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px; min-height: 80px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column;
  animation: fadeIn 0.25s ease both;
}
.day-cell:hover { border-color: var(--accent); background: var(--bg3); box-shadow: 0 2px 10px rgba(80,50,10,0.08); }
.day-cell.today { border-color: var(--accent); background: rgba(176,125,58,0.07); }
.day-cell.empty { background: transparent; border-color: transparent; cursor: default; pointer-events: none; }

.day-num { font-size: 13px; font-weight: 600; color: var(--muted); line-height: 1; }
.day-cell.today .day-num { color: var(--accent); font-size: 14px; }

.day-note-preview {
  font-size: 10px; color: var(--accent);
  margin-top: 5px; line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.day-note-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
}

/* ─── NOTE VIEW MODAL ─── */
.note-view-box { width: 560px; max-width: 95vw; }
.note-view-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 1rem;
}
.note-view-header .modal-title { margin-bottom: 0; }
.modal-close-btn {
  background: none; border: none;
  color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 2px 6px;
  border-radius: 6px; line-height: 1;
  transition: color .2s, background .2s;
  flex-shrink: 0; margin-top: 4px;
}
.modal-close-btn:hover { color: var(--text); background: var(--bg3); }
.note-view-content {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px 16px; min-height: 140px; max-height: 340px;
  overflow-y: auto; font-size: 14px; line-height: 1.7;
  color: var(--text); white-space: pre-wrap; word-break: break-word;
  margin-bottom: 0;
}
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(60,35,10,0.35);
  display: none; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 1.75rem; width: 420px; max-width: 95vw;
  animation: fadeUp 0.25s ease;
  box-shadow: 0 8px 36px rgba(80,50,10,0.15);
}

.modal-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px; color: var(--text); margin-bottom: 1rem;
}
.modal-title span { color: var(--accent); font-style: italic; }

.modal-box textarea {
  width: 100%; min-height: 130px;
  background: var(--bg); border: 1px solid var(--border2);
  border-radius: var(--radius); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 14px;
  padding: 10px 12px; resize: vertical; outline: none;
  line-height: 1.6; transition: border-color 0.2s;
}
.modal-box textarea:focus { border-color: var(--accent); }
.modal-box textarea::placeholder { color: var(--muted); }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1rem; }

.btn-save { background: var(--accent); color: #faf5ec; font-weight: 600; padding: 8px 20px; }
.btn-save:hover { background: var(--accent2); }

/* ─── ADMIN ─── */
#s-admin { padding: 1.5rem; }

.admin-title {
  font-family: 'DM Serif Display', serif;
  font-size: 28px; color: var(--text); margin-bottom: 1.5rem;
}
.admin-title span { color: var(--accent); }

.users-table-wrap {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 12px rgba(80,50,10,0.06);
}

.users-search-bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border2);
  background: var(--bg3);
}
.users-search-bar .search-icon { font-size: 14px; opacity: 0.5; flex-shrink: 0; }
.users-search-bar input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 13px; font-family: inherit;
}
.users-search-bar input::placeholder { color: var(--muted); }
.search-count { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.no-results { text-align: center; padding: 1.5rem; font-size: 13px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border2); }
th {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 10px 16px;
  text-align: left; background: var(--bg3);
}
td { padding: 10px 16px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

.badge { display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 10px; border-radius: 20px; }
.badge-admin { background: rgba(176,125,58,0.14); color: var(--accent); border: 1px solid rgba(176,125,58,0.32); }
.badge-user  { background: rgba(78,140,94,0.12); color: var(--success); border: 1px solid rgba(78,140,94,0.28); }

.add-user-card {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 12px rgba(80,50,10,0.06);
}

.add-user-card h3 {
  font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 1rem; letter-spacing: 0.02em;
}

.add-user-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 120px auto;
  gap: 8px; align-items: end;
}

/* ─── LOADING ─── */
.loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; transition: opacity 0.3s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 36px; height: 36px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── TOAST ─── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 10px 16px;
  font-size: 13px; color: var(--text);
  z-index: 300; transform: translateY(20px); opacity: 0;
  transition: all 0.25s; pointer-events: none;
  box-shadow: 0 4px 16px rgba(80,50,10,0.12);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(78,140,94,0.4); color: var(--success); }
.toast.error   { border-color: rgba(192,80,60,0.4); color: var(--danger); }

/* ─── ANIMATIONS ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── MONTH STAGGER ─── */
.month-card:nth-child(1)  { animation-delay: 0.00s; }
.month-card:nth-child(2)  { animation-delay: 0.03s; }
.month-card:nth-child(3)  { animation-delay: 0.06s; }
.month-card:nth-child(4)  { animation-delay: 0.09s; }
.month-card:nth-child(5)  { animation-delay: 0.12s; }
.month-card:nth-child(6)  { animation-delay: 0.15s; }
.month-card:nth-child(7)  { animation-delay: 0.18s; }
.month-card:nth-child(8)  { animation-delay: 0.21s; }
.month-card:nth-child(9)  { animation-delay: 0.24s; }
.month-card:nth-child(10) { animation-delay: 0.27s; }
.month-card:nth-child(11) { animation-delay: 0.30s; }
.month-card:nth-child(12) { animation-delay: 0.33s; }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  .months-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .months-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .add-user-grid { grid-template-columns: 1fr 1fr; }
  .year-heading { font-size: 40px; }
}

/* ─── ADMIN LINK EN LOGIN ─── */
.admin-link-wrap { margin-top: 1.2rem; text-align: center; }
.admin-link {
  color: var(--accent); font-size: 13px;
  letter-spacing: 0.04em; cursor: pointer;
  opacity: 0.75; transition: opacity .2s; text-decoration: none;
}
.admin-link:hover { opacity: 1; }

/* ─── PANTALLA ADMIN LOGIN ─── */
#s-admin-login {
  align-items: center; justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(176,125,58,0.13) 0%, transparent 70%);
}
#s-admin-login .login-wrap {
  display: flex; align-items: center; justify-content: center;
  width: 100%; flex: 1;
}
.admin-login-box { border-color: rgba(176,125,58,0.32); }
.admin-login-icon { font-size: 2rem; text-align: center; margin-bottom: .4rem; filter: sepia(1) saturate(3) hue-rotate(5deg); }
.admin-login-title { letter-spacing: .12em; }

/* ─── ADMIN CONTENT CENTERED ─── */
.admin-content { padding: 1.5rem; max-width: 900px; width: 100%; margin: 0 auto; }

/* ─── EDIT / DELETE BUTTONS ─── */
.btn-edit {
  background: transparent;
  border: 1px solid rgba(176,125,58,0.35);
  color: var(--accent); font-size: 12px; padding: 4px 10px;
}
.btn-edit:hover { background: rgba(176,125,58,0.10); }

.action-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.btn-danger-solid {
  background: rgba(192,80,60,0.12);
  border: 1px solid rgba(192,80,60,0.4);
  color: var(--danger); font-size: 13px; padding: 8px 18px;
}
.btn-danger-solid:hover { background: rgba(192,80,60,0.22); }

.modal-box-sm { width: 380px; }
