/* ESTILOS MAESTROS - MIWEBNUESTRA (PWA APPLE MINIMALISTA) */

:root {
  --font-family: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Helvetica Neue", sans-serif;
  --bg-primary: #f5f5f7;
  --bg-surface: #ffffff;
  --bg-subtle: #f0f0f4;
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --accent-blue: #0071e3;
  --accent-blue-active: #0077ed;
  --accent-blue-hover: #005bb5;
  --accent-red: #ff3b30;
  --accent-red-hover: #d70015;
  --accent-green: #34c759;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-active: rgba(0, 113, 227, 0.3);
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-modal: 0 -8px 30px rgba(0, 0, 0, 0.12);
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-sheet: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 96px;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* AUTH OVERLAY */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-overlay.hidden {
  display: none !important;
}

.auth-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-subtle);
  text-align: center;
}

.auth-card h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.auth-card .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.auth-error-msg {
  background: rgba(255, 59, 48, 0.1);
  color: var(--accent-red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
  text-align: left;
}

/* TOP BAR */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(245, 245, 247, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

.user-pill-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
}

.user-status {
  font-size: 11px;
  color: var(--accent-green);
  font-weight: 500;
}

.icon-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* CONTENEDOR SECCIONES */
.app-container {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.app-section {
  display: none;
}

.app-section.active {
  display: block;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title-row h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.6px;
}

.section-title-row .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

/* BOTONES APPLE */
.btn-apple-circle {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
  transition: transform var(--transition-fast);
}

.btn-apple-circle:active {
  transform: scale(0.92);
}

.btn-apple-primary {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.btn-apple-primary:active {
  background: var(--accent-blue-active);
  transform: scale(0.98);
}

.btn-apple-secondary {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-apple-danger {
  background: rgba(255, 59, 48, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(255, 59, 48, 0.2);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-apple-danger-confirm {
  background: var(--accent-red) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.35);
}

.btn-apple-whatsapp {
  background: #25d366;
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-apple-add {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* SEGMENTED CONTROL */
.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 3px;
  border-radius: var(--radius-md);
  gap: 3px;
  margin-bottom: 16px;
}

.seg-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.seg-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* CALENDARIO */
.calendar-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.calendar-header-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.cal-month-title {
  font-size: 16px;
  font-weight: 700;
}

.cal-nav-btn {
  background: var(--bg-subtle);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
}

.cal-day-cell.other-month {
  color: #c7c7cc;
}

.cal-day-cell.selected {
  background: var(--text-primary);
  color: #fff;
  font-weight: 700;
}

.cal-day-cell.today:not(.selected) {
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
  font-weight: 700;
}

.cal-dots {
  position: absolute;
  bottom: 2px;
  display: flex;
  gap: 2px;
}

.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--accent-blue);
}

.cal-dot.partner {
  background: #bf5af2;
}

/* LISTAS DE TARJETAS */
.subcard-list-header {
  margin-bottom: 10px;
}

.subcard-list-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.events-list, .tasks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* TARJETA DINÁMICA DE EVENTOS (CON SOPORTE DE GRADIENTE DE GRISES) */
.event-item-card {
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-surface);
  transition: background-color var(--transition-fast);
}

.event-item-card.is-future-gradient {
  /* Controlado dinámicamente mediante variables inline en script.js */
  background-color: var(--card-bg-gradient, #ffffff);
}

.event-item-card.event-past-black {
  background-color: #1c1c1e !important;
  color: #ffffff !important;
  border-color: #2c2c2e !important;
}

.event-item-card.event-past-black .event-title,
.event-item-card.event-past-black .event-subtitle {
  color: #ffffff !important;
}

.event-card-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.event-title {
  font-size: 15px;
  font-weight: 600;
}

.event-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.event-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-pill {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-mine {
  background: rgba(0, 113, 227, 0.12);
  color: var(--accent-blue);
}

.badge-partner {
  background: rgba(191, 90, 242, 0.12);
  color: #bf5af2;
}

.badge-shared {
  background: rgba(255, 149, 0, 0.12);
  color: #ff9500;
}

/* TARJETAS DE NOTAS & EVENTOS EN SECCIÓN NOTAS */
.task-note-card {
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.task-note-card.note-white {
  background: #ffffff;
}

.task-note-card.event-blue-card {
  background: #0071e3 !important;
  color: #ffffff !important;
  border: none !important;
}

.task-note-card.event-blue-card .task-title,
.task-note-card.event-blue-card .task-details,
.task-note-card.event-blue-card .task-meta {
  color: #ffffff !important;
}

.task-note-card.event-past-card {
  background: #1c1c1e !important;
  color: #ffffff !important;
  border: none !important;
}

.task-note-card.event-past-card .task-title,
.task-note-card.event-past-card .task-details,
.task-note-card.event-past-card .task-meta {
  color: #ffffff !important;
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.task-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-details {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-line;
}

.task-footer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.task-edit-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  color: inherit;
  opacity: 0.85;
}

.task-edit-btn:hover {
  opacity: 1;
}

/* CARTERA CARDS */
.balance-cards-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
  scroll-snap-type: x mandatory;
}

.apple-card {
  flex: 0 0 85%;
  border-radius: var(--radius-xl);
  padding: 20px;
  color: #fff;
  box-shadow: var(--shadow-md);
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
}

.my-card {
  background: linear-gradient(135deg, #1d1d1f 0%, #3a3a3c 100%);
}

.shared-card {
  background: linear-gradient(135deg, #0071e3 0%, #42a5f5 100%);
}

.partner-card {
  background: linear-gradient(135deg, #5856d6 0%, #af52de 100%);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-brand {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
}

.card-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-chip {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
}

.card-edit-btn {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  font-size: 12px;
  cursor: pointer;
}

.card-balance {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  margin: 12px 0;
}

.card-footer {
  font-size: 12px;
  opacity: 0.8;
}

.transactions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transaction-item {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  border: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tx-amount.expense {
  color: var(--accent-red);
  font-weight: 600;
}

.tx-amount.income {
  color: var(--accent-green);
  font-weight: 600;
}

/* LISTA DE LA COMPRA */
.quick-add-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.quick-add-bar input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 15px;
}

.shopping-actions-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.text-action-btn {
  background: transparent;
  border: none;
  font-size: 13px;
  color: var(--accent-blue);
  cursor: pointer;
  font-weight: 500;
}

.text-action-btn.danger {
  color: var(--accent-red);
}

.shopping-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shopping-item-row {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.shopping-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shopping-checkbox {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.shopping-item-row.completed .shopping-checkbox {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.shopping-item-row.completed .shopping-checkbox::after {
  content: "✓";
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.shopping-item-row.completed span.item-name {
  text-decoration: line-through;
  color: var(--text-secondary);
}

/* BOTTOM DOCK */
.bottom-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  z-index: 200;
}

.dock-item {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.dock-item.active {
  color: var(--accent-blue);
}

.dock-icon {
  font-size: 20px;
}

.dock-label {
  font-size: 11px;
  font-weight: 500;
}

/* FORMULARIOS Y MODALES */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop.open {
  display: flex;
}

.modal-sheet {
  background: var(--bg-surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-modal);
  animation: slideUp var(--transition-sheet);
}

.modal-sheet-dialog {
  border-radius: var(--radius-xl);
  margin-bottom: auto;
  margin-top: auto;
  max-width: 360px;
  text-align: center;
  padding: 24px 20px;
}

.dialog-icon-alert {
  font-size: 38px;
  margin-bottom: 8px;
}

.dialog-content h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.dialog-content p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.dialog-actions-row {
  display: flex;
  gap: 10px;
}

.dialog-actions-row button {
  flex: 1;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-indicator {
  width: 36px;
  height: 5px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-full);
  margin: 0 auto 12px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close-btn {
  background: var(--bg-subtle);
  border: none;
  border-radius: var(--radius-full);
  width: 30px;
  height: 30px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent-blue);
  background: #fff;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-group {
  flex: 1;
}

.field-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: -8px;
  margin-bottom: 12px;
  font-style: italic;
}

.form-group-switch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 14px 0;
  font-size: 14px;
  font-weight: 500;
}

/* APPLE SWITCH */
.apple-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.apple-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #e5e5ea;
  border-radius: var(--radius-full);
  transition: .25s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: var(--radius-full);
  transition: .25s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background-color: var(--accent-green);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* SETTINGS MODAL */
.settings-group {
  margin-bottom: 20px;
}

.group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: block;
}

.settings-inner-card {
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  border: 1px solid var(--border-subtle);
}

.link-bullet {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  margin-right: 6px;
}

.link-bullet.connected {
  background: var(--accent-green);
}

.hidden {
  display: none !important;
}