/* ============================================
   Dashboard v2 — Tema oscuro profesional
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg:        #0a0b0d;
  --bg-card:   #14161a;
  --bg-elev:   #1c1f25;
  --bg-input:  #1c1f25;
  --border:    #23272f;
  --border-strong: #2e333d;
  --text:      #e8eaed;
  --text-soft: #8a9099;
  --text-faint:#5a6068;
  --accent:    #b3cef6;
  --accent-2:  #7c9eff;
  --accent-soft: rgba(179, 206, 246, 0.1);
  --success:   #7dd3a8;
  --danger:    #ec7373;
  --warning:   #f5b76b;
  --radius:    10px;
  --radius-lg: 14px;
  --sidebar-w: 220px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ====== LOGIN ====== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at top, rgba(179, 206, 246, 0.04), transparent 60%), var(--bg);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%; max-width: 380px;
}
.login-card h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.login-card .subtitle { margin: 0 0 28px; color: var(--text-soft); font-size: 14px; }
.login-card label { display: block; margin-bottom: 16px; }
.login-card label span { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; font-weight: 500; }
.login-card input {
  width: 100%; padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button {
  width: 100%; margin-top: 8px; padding: 12px;
  background: var(--accent); color: #0a0b0d;
  border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: #c9dcfb; }
.alert { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert.error { background: rgba(236, 115, 115, 0.1); color: var(--danger); border: 1px solid rgba(236, 115, 115, 0.25); }

/* ====== SIDEBAR ====== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  z-index: 5;
}
.sidebar-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 0 10px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.nav-item:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-icon { width: 18px; text-align: center; opacity: 0.9; font-size: 15px; }
.sidebar-foot {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-foot .user-name { flex: 1; font-size: 13px; color: var(--text-soft); padding-left: 6px; }

/* ====== MAIN ====== */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 28px 36px;
}

.view { display: none; }
.view.active { display: block; }

.view-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.view-head h1 {
  margin: 0 0 4px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em;
}
.view-sub { margin: 0; color: var(--text-soft); font-size: 13.5px; }
.view-head > div { flex: 1; min-width: 200px; }

/* ====== BOTONES ====== */
.btn-primary {
  padding: 8px 16px; background: var(--accent); color: #0a0b0d;
  border: none; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all 0.15s ease;
}
.btn-primary:hover { background: #c9dcfb; transform: translateY(-1px); }

.btn-ghost {
  padding: 7px 12px; background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px;
  color: var(--text-soft); cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-ghost:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-icon {
  background: transparent; border: none;
  color: var(--text-faint); cursor: pointer;
  font-size: 16px; padding: 4px 8px;
  border-radius: 6px; line-height: 1;
  transition: all 0.15s ease;
}
.btn-icon:hover { background: rgba(236, 115, 115, 0.12); color: var(--danger); }

/* ====== DASHBOARD GRID ====== */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-wide { grid-column: 1 / -1; }
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px; gap: 10px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--text-faint); font-size: 12px; }

/* ====== EVENTOS DEL DASHBOARD ====== */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-row {
  display: flex; align-items: stretch; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.event-row:last-child { border-bottom: none; }
.event-bar { width: 3px; border-radius: 2px; flex-shrink: 0; }
.event-info { flex: 1; }
.event-info strong { display: block; font-size: 14px; margin-bottom: 2px; }
.event-info small { color: var(--text-soft); font-size: 12px; }

/* ====== TASK MINI ====== */
.task-list-mini { list-style: none; margin: 0; padding: 0; }
.task-mini {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.task-mini:last-child { border-bottom: none; }
.task-mini .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.task-mini .task-title { flex: 1; }
.task-mini.pinned::before { content: '📌'; font-size: 11px; }

.due-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 4px;
  background: var(--bg-elev); color: var(--text-soft); white-space: nowrap;
}
.due-tag.today { background: rgba(245, 183, 107, 0.15); color: var(--warning); }
.due-tag.tomorrow { background: rgba(179, 206, 246, 0.15); color: var(--accent); }
.due-tag.soon { background: var(--bg-elev); color: var(--text-soft); }
.due-tag.overdue { background: rgba(236, 115, 115, 0.15); color: var(--danger); font-weight: 600; }

/* ====== DESTACADOS ====== */
.pinned-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.pinned-note {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.pinned-note strong { display: block; font-size: 13.5px; margin-bottom: 6px; }
.pinned-note p { margin: 0; font-size: 13px; color: var(--text-soft); }

/* ====== CALENDARIO SEMANAL ====== */
.week-nav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.calendar-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cal-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  position: relative;
}
.cal-corner {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 3;
}
.cal-day-head {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  text-align: center;
  position: sticky; top: 0; z-index: 3;
}
.cal-day-head:last-child { border-right: none; }
.cal-day-head .dn { display: block; font-size: 11px; text-transform: uppercase; color: var(--text-soft); letter-spacing: 0.05em; }
.cal-day-head .dd { display: block; font-size: 18px; font-weight: 600; margin-top: 2px; }
.cal-day-head.today .dd { color: var(--accent); }
.cal-day-head.today { background: var(--accent-soft); }

.cal-hour {
  padding: 4px 8px; font-size: 11px;
  color: var(--text-faint); text-align: right;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  height: 60px;
}
.cal-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  height: 60px; cursor: pointer;
  transition: background 0.15s ease;
}
.cal-cell:hover { background: var(--bg-elev); }
.cal-cell:nth-child(8n) { border-right: none; }

.cal-event {
  position: absolute;
  left: 2px; right: 2px;
  border-left: 3px solid;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11.5px;
  cursor: pointer;
  overflow: hidden;
  z-index: 2;
  /* offset para alinear con la cuadrícula de horas (cada hora = 60px) */
  margin-top: 0;
}
.cal-event strong { display: block; font-size: 12px; margin-bottom: 2px; }
.cal-event small { color: var(--text-soft); font-size: 10.5px; }
.cal-event:hover { filter: brightness(1.2); }

/* ====== TAREAS LISTA ====== */
.tasks-container { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  transition: all 0.15s ease;
}
.task-card:hover { border-color: var(--border-strong); }
.task-card.pinned { background: linear-gradient(to right, var(--accent-soft), var(--bg-card) 30%); }
.task-card input[type="checkbox"] {
  appearance: none;
  width: 20px; height: 20px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  background: var(--bg-input);
}
.task-card input[type="checkbox"]:checked {
  background: var(--accent); border-color: var(--accent);
}
.task-card input[type="checkbox"]:checked::after {
  content: "✓"; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: var(--bg); font-size: 13px; font-weight: 800;
}
.task-body { flex: 1; }
.task-row1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.task-row1 strong { font-size: 14px; font-weight: 500; }
.cat-tag { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.task-actions { display: flex; gap: 4px; }
.task-actions .btn-icon:hover { background: var(--bg-elev); color: var(--accent); }
.task-actions .btn-icon[data-delete]:hover { background: rgba(236, 115, 115, 0.12); color: var(--danger); }

/* ====== NOTAS ====== */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.note {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.15s ease;
}
.note:hover { border-color: var(--border-strong); }
.note.pinned {
  border-color: var(--accent);
  background: linear-gradient(to bottom, var(--accent-soft), var(--bg-card) 60%);
}
.note header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.note header strong { font-size: 14px; font-weight: 600; flex: 1; }
.note-actions { display: flex; gap: 2px; }
.note-actions .btn-icon { font-size: 14px; padding: 2px 6px; }
.note p {
  margin: 0 0 10px;
  font-size: 13px; color: var(--text-soft);
  white-space: pre-wrap; word-wrap: break-word;
}
.note time { font-size: 11px; color: var(--text-faint); }

/* ====== CATEGORÍAS ====== */
.cat-form {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius);
}
.cat-form input[type="text"] {
  flex: 1; padding: 8px 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px;
}
.cat-form input[type="color"] {
  width: 42px; height: 38px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
  padding: 2px;
}
.cat-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.cat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cat-color {
  width: 14px; height: 14px;
  border-radius: 50%; flex-shrink: 0;
}
.cat-item span:not(.cat-color) { flex: 1; font-size: 14px; }

/* ====== FORMULARIOS / INPUTS ====== */
input[type="text"], input[type="datetime-local"], textarea, select {
  font-family: inherit; font-size: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 70px; }

/* ====== MODAL ====== */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h2 { margin: 0 0 18px; font-size: 18px; font-weight: 600; }
.modal label {
  display: block; margin-bottom: 14px;
  font-size: 12.5px; color: var(--text-soft); font-weight: 500;
}
.modal label input, .modal label textarea, .modal label select {
  margin-top: 5px;
}
.modal .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-label {
  display: flex !important; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
}
.check-label input { width: auto !important; margin: 0 !important; }
.modal-actions {
  display: flex; gap: 8px; align-items: center;
  margin-top: 20px;
}

/* ====== EMPTY ====== */
.empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
  padding: 28px 12px;
  font-style: italic;
  list-style: none;
}

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ====== RESPONSIVE ====== */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }
  .sidebar { padding: 14px 6px; }
  .sidebar-brand, .nav-item span:not(.nav-icon), .sidebar-foot .user-name, .sidebar-foot .btn-ghost { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .main { padding: 20px 18px; }
  .dash-grid { grid-template-columns: 1fr; }
  .calendar-wrapper { overflow-x: auto; }
  .cal-grid { min-width: 700px; }
}
@media (max-width: 600px) {
  .modal .form-row { grid-template-columns: 1fr; }
}
