/**
 * SePagos - Minimalist Responsive CSS
 * Clean mobile-first design system
 */

:root {
  --primary: #025B93;
  --primary-hover: #002857;
  --primary-light: #e6f5fc;
  --secondary: #10A1DD;
  --accent: #EE7900;
  --accent-light: #fff3e6;
  --navy: #002857;
  --navy-light: #0a3d75;
  --text-main: #002857;
  --text-muted: #5b6b82;
  --text-light: #94a3b8;
  --bg-page: #f5f9fc;
  --bg-card: #ffffff;
  --border: #dde7f0;
  --border-focus: #10A1DD;
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --bottom-nav-height: 64px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: contain;
  touch-action: manipulation;
}

/* Comportamiento de app nativa: sin selección/copia ni menú contextual salvo en campos de texto */
body.app-native,
body.app-native * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.app-native input,
body.app-native textarea,
body.app-native select,
body.app-native [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

img, a {
  -webkit-user-drag: none;
}

/* Ordenar listado */
.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.sort-select {
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
}

/* Pull-to-refresh */
#ptr-indicator {
  position: fixed;
  top: -44px;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--text-muted);
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  z-index: 3000;
}
#ptr-indicator.visible { opacity: 1; }
#ptr-indicator.ready { color: var(--primary); }

.refresh-btn.spinning svg { animation: ptr-spin 0.8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Typography & Helpers
   ========================================================================== */
h1, h2, h3, h4, h5 {
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.hidden { display: none !important; }

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.app-header {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(0, 40, 87, 0.3);
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: #fff;
}

.brand-badge {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.5px;
}

.nav-links {
  display: none;
  gap: 6px;
  align-items: center;
}

.nav-link {
  color: #cbd5e1;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary);
  color: #fff;
}

.user-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.plan-badge {
  background: rgba(255, 255, 255, 0.15);
  color: #f8fafc;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.plan-badge:hover {
  background: rgba(255, 255, 255, 0.25);
}

.btn-icon {
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Bottom Navigation for Mobile */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: #ffffff;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 40;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.bnav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

.bnav-item.active {
  color: var(--primary);
}

/* ==========================================================================
   Layout Container
   ========================================================================== */
.main-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
  margin-bottom: calc(var(--bottom-nav-height) + 10px);
}

@media (min-width: 768px) {
  .nav-links { display: flex; }
  .bottom-nav { display: none; }
  .main-container { margin-bottom: 30px; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
  text-decoration: none;
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #059669;
  color: #fff;
  text-decoration: none;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
  color: #fff;
  text-decoration: none;
}

.btn-outline {
  background: #fff;
  color: var(--text-main);
  border-color: var(--border);
}
.btn-outline:hover {
  background: #f1f5f9;
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: #f1f5f9;
  color: var(--text-main);
  text-decoration: none;
}

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

.btn-lg {
  padding: 14px 24px;
  font-size: 16px;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   Cards & Summaries
   ========================================================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 20px;
  transition: all 0.2s;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.metric-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.metric-card.cobro {
  border-left: 5px solid var(--success);
}

.metric-card.pago {
  border-left: 5px solid var(--danger);
}

.metric-card.balance {
  border-left: 5px solid var(--primary);
}

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

.metric-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

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

.metric-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.metric-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   Quick Actions & Section Headers
   ========================================================================== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Search & Filters Bar
   ========================================================================== */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--border-focus);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pill-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.pill-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ==========================================================================
   Records List & Record Cards
   ========================================================================== */
.records-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.record-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  cursor: pointer;
}

.record-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.record-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.record-contact {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-concept {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.record-amounts {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px solid #f1f5f9;
  padding-top: 12px;
}

.amount-group {
  display: flex;
  flex-direction: column;
}

.amount-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.amount-current {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
}

.amount-initial {
  font-size: 12px;
  color: var(--text-muted);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-cobro { background: var(--success-light); color: var(--success); }
.badge-pago { background: var(--danger-light); color: var(--danger); }
.badge-pendiente { background: #fef2f2; color: #dc2626; }
.badge-parcial { background: #fffbeb; color: #d97706; }
.badge-pagado { background: #ecfdf5; color: #059669; }

/* Progress Bar */
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: #f1f5f9;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-green { background: var(--success); }
.progress-blue { background: var(--primary); }

/* ==========================================================================
   Forms & Modals
   ========================================================================== */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: #fff;
  color: var(--navy);
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 161, 221, 0.18);
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

.form-help {
  font-size: 12px;
  color: var(--text-muted);
}

/* Modal System */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 40, 87, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-box {
  transform: translateY(0);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Currency input highlight */
.currency-input-wrap {
  position: relative;
}

.currency-symbol {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}

.currency-input {
  padding-left: 32px !important;
  font-weight: 700;
  font-size: 16px !important;
}

/* ==========================================================================
   Movements History in Detail
   ========================================================================== */
.movement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.movement-item:last-child {
  border-bottom: none;
}

.movement-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.movement-date {
  font-size: 11px;
  color: var(--text-light);
}

.movement-note {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}

.movement-right {
  text-align: right;
  display: flex;
  align-items: center;
  gap: 12px;
}

.movement-amount {
  font-size: 14px;
  font-weight: 800;
}

.movement-balance-after {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   Plans & Subscription Cards
   ========================================================================== */
.plans-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

@media (min-width: 768px) {
  .plans-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: #fff;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all 0.2s;
}

.plan-card.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.plan-card.popular {
  border-color: var(--accent);
}

.plan-tag {
  position: absolute;
  top: -10px;
  right: 18px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.plan-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
}

.plan-price {
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 12px;
}

.plan-price span {
  font-size: 14px;
  font-weight: normal;
  color: var(--text-muted);
}

.plan-features {
  list-style: none;
  margin-bottom: 20px;
  flex: 1;
}

.plan-features li {
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Toasts & Alerts
   ========================================================================== */
#toast-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 340px;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--primary); }

@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   PWA Install Prompt
   ========================================================================== */
.pwa-banner {
  background: linear-gradient(135deg, var(--navy) 0%, var(--primary) 100%);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.pwa-banner-text h4 {
  color: #fff;
  font-size: 14px;
}

.pwa-banner-text p {
  font-size: 12px;
  color: #cbd5e1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto 16px;
}
