@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

/* Capa de diseno v2: mobile first (se carga despues de app.css) */
:root {
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 1rem;
  --radius-lg: 1.25rem;
  --brand-grad: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  --shadow-lift: 0 14px 34px rgba(15, 118, 110, 0.22);
  --bottom-nav-h: 64px;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
}

.reports-eyebrow,
.agenda-event-time { color: var(--brand); }
.reports-title,
.reports-preview-title,
.agenda-day-title,
.agenda-event-title { color: var(--text-strong); }
.agenda-day-subtitle,
.agenda-event-meta,
.agenda-empty-day,
.agenda-status { color: var(--text-muted); }

/* Navbar superior */
.app-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  padding: 0.5rem 0;
  background: color-mix(in srgb, var(--surface-strong) 86%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-size: 1.15rem !important;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.navbar-brand::before {
  content: '';
  width: 2rem;
  height: 2rem;
  border-radius: 0.65rem;
  background: center/60% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M8 3v4M16 3v4M3 10h18'/%3E%3C/svg%3E");
  background-color: #0f766e;
  box-shadow: 0 6px 14px rgba(15, 118, 110, 0.3);
}

[data-theme='dark'] .btn-outline-primary { color: #5eead4; border-color: rgba(94, 234, 212, 0.4); }
[data-theme='dark'] .btn-outline-primary:hover { background: rgba(94, 234, 212, 0.12); color: #99f6e4; }
[data-theme='dark'] .fc .fc-button-primary:disabled { color: var(--text-muted); }

.calendar-user { gap: 0.5rem !important; flex-wrap: nowrap; }

.btn {
  border-radius: 0.75rem;
  font-weight: 600;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-sm { min-height: 2.25rem; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand-grad); border: 0; box-shadow: 0 6px 16px rgba(15, 118, 110, 0.25); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); }
.btn-secondary { border: 0; }

.card, .modal-content, .calendar-toolbar, .calendar-filters, .report-preview { border-radius: var(--radius-lg) !important; }
.card { border: 1px solid var(--border-soft) !important; }

.form-control, .form-select {
  min-height: 2.9rem;
  font-size: 1rem;
  border-radius: 0.8rem;
}
select[multiple].form-select { min-height: 0; }
.form-label { font-weight: 600; font-size: 0.88rem; margin-bottom: 0.35rem; }
.form-control-color { width: 100%; padding: 0.35rem; }

.reports-title { font-weight: 800; letter-spacing: -0.02em; }

.dashboard-hero { flex-direction: column; }
.dashboard-stat-card { border-radius: var(--radius-lg); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.dashboard-stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.dashboard-stat-value { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dashboard-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.dashboard-ranking-bar span { background: var(--brand-grad); }
.dashboard-event-row { transition: border-color 0.2s, transform 0.2s; }
.dashboard-event-row:hover { border-color: var(--brand); transform: translateX(2px); }

/* Calendario */
.calendar-toolbar-actions .btn { flex: 1 1 auto; }
.fc { --fc-border-color: var(--border-soft); font-family: var(--font-ui); }
.fc .fc-toolbar-title { font-weight: 800; letter-spacing: -0.02em; }
.fc .fc-toolbar-title::first-letter { text-transform: uppercase; }
.fc .fc-button { border-radius: 0.7rem !important; font-weight: 600; min-height: 2.4rem; }
.fc .fc-button-primary { background: var(--surface-soft); color: var(--text-strong); border-color: var(--border-strong); }
.fc .fc-button-primary:hover { background: var(--surface-muted); border-color: var(--brand); color: var(--brand); }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { background: var(--brand-grad); color: #fff; border-color: transparent; box-shadow: none; }
.fc .fc-button-primary:disabled { opacity: 0.5; }
.fc .fc-button:focus { box-shadow: 0 0 0 0.2rem rgba(15, 118, 110, 0.2) !important; }
.fc-theme-standard .fc-scrollgrid { border-radius: var(--radius); overflow: hidden; }
.fc .fc-event { border-radius: 0.5rem; border: 0; padding: 1px 3px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); cursor: pointer; }
.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  background: var(--brand-grad); color: #fff; border-radius: 999px; min-width: 1.6rem; text-align: center; margin: 3px;
}
.fc .fc-col-header-cell { padding: 0.4rem 0; background: var(--surface-muted); }

.agenda-event-card { border-radius: var(--radius); border-left: 4px solid var(--brand); transition: transform 0.15s, box-shadow 0.15s; }
.agenda-event-card:active { transform: scale(0.99); }
.agenda-day-header { border-radius: var(--radius); }

/* Modales */
.modal-content { overflow: hidden; border: 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25); }
.modal-header { padding: 1rem 1.25rem; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 0.85rem 1.25rem calc(0.85rem + env(safe-area-inset-bottom)); }
.modal-title { font-weight: 800; }
[data-theme='dark'] .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.recurrence-day-option { cursor: pointer; min-height: 2.75rem; }
.recurrence-day-option:has(input:checked) { background: var(--surface-soft); border-color: var(--brand); }

/* Barra inferior y FAB (movil) */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1040;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding: 0.3rem 0.5rem env(safe-area-inset-bottom);
  display: flex;
  justify-content: space-around;
  background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.06);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  max-width: 6.5rem;
  border-radius: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
}
.bottom-nav a svg { width: 1.4rem; height: 1.4rem; }
.bottom-nav a.is-active { color: var(--brand); background: var(--surface-soft); }
.bottom-nav a.is-danger { color: #dc2626; }

.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 0.9rem);
  z-index: 1035;
  width: 3.5rem; height: 3.5rem;
  border: 0; border-radius: 1.1rem;
  display: grid; place-items: center;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: var(--shadow-lift);
  transition: transform 0.15s ease;
}
.fab:active { transform: scale(0.92); }
.fab svg { width: 1.7rem; height: 1.7rem; }

/* Login / registro */
.auth-bg { padding-bottom: 0; min-height: 100dvh; display: flex; align-items: center; }
.auth-bg main { width: 100%; padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.auth-bg .card { box-shadow: 0 24px 60px rgba(15, 118, 110, 0.18) !important; }
.auth-bg h1 { font-weight: 800; letter-spacing: -0.02em; }

@media (max-width: 767.98px) {
  .calendar-user > a, .calendar-user .welcome-text, .calendar-toolbar-actions > a { display: none !important; }
  .calendar-nav-wrap { flex-wrap: nowrap !important; }
  .calendar-main { padding: 0.5rem !important; }
  .calendar-toolbar { padding: 0.5rem; }
  .calendar-toolbar-actions { width: 100%; }
  .calendar-filter-summary { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .calendar-filter-badge { white-space: nowrap; font-size: 0.75rem; }
  .modal-dialog { margin: 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: none; width: 100%; }
  .modal.fade:not(.show) .modal-dialog { transform: translateY(100%); }
  .modal-content { border-radius: 1.5rem 1.5rem 0 0 !important; max-height: 92dvh; }
  #eventForm.modal-content { display: flex; flex-direction: column; }
  #eventForm .modal-body { overflow-y: auto; }
  .fc .fc-toolbar-title { font-size: 1.15rem; }
  .fc .fc-toolbar .fc-button-group { grid-template-columns: repeat(4, 1fr); }
  .fc .fc-toolbar .fc-button { font-size: 0.72rem; padding: 0.3rem 0.2rem; }
  .fc .fc-timegrid-slot-label-cushion, .fc .fc-timegrid-axis-cushion { font-size: 0.68rem; }
  .fc-weekday-label { font-size: 0.68rem; }
  .fc-weekday-number { font-size: 0.9rem; }
  .fc .fc-toolbar-chunk:first-child { display: flex; gap: 0.4rem; }
  .fc .fc-toolbar-chunk:first-child .fc-button-group { display: flex; width: auto; flex: 1; gap: 0.4rem; }
  .fc .fc-toolbar-chunk:first-child .fc-button-group .fc-button { flex: 1; }
  .fc .fc-toolbar-chunk:first-child > .fc-today-button { flex: 1; width: auto; }
}

@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .fab { bottom: 1.5rem; right: 1.5rem; }
  .navbar-brand { font-size: 1.35rem !important; }
  .modal-content { box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3); }
  .dashboard-hero { flex-direction: row; }
  .dashboard-stats-grid { gap: 0.9rem; }
  .calendar-user > a.active { background: var(--surface-soft); color: var(--brand); border-color: var(--brand); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
