/* styles.css */
:root {
  --primary-color: #1e40af; /* Azul fuerte accesible */
  --primary-hover: #1d4ed8;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  
  --color-success: #15803d; /* Verde legible */
  --color-success-bg: #dcfce7;
  --color-pending: #b91c1c; /* Rojo de deuda */
  --color-pending-bg: #fee2e2;
  --color-warning: #c2410c; /* Naranja parcial */
  --color-warning-bg: #ffedd5;
  
  --radius: 16px;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-user-select: none;
  user-select: none;
}

/* Pantallas */
.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ========================================== */
/* PANTALLA PIN                               */
/* ========================================== */
#pin-screen {
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  color: white;
}

.pin-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 28px 20px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  color: var(--text-main);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.app-logo-login {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.app-logo-header {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  background: white;
  padding: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.pin-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.pin-header p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
}

.pin-display .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  transition: all 0.2s ease;
}

.pin-display .dot.filled {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  transform: scale(1.15);
}

.error-msg {
  color: var(--color-pending);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.key-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  height: 56px;
  cursor: pointer;
  transition: active 0.1s;
}

.key-btn:active {
  background: #cbd5e1;
  transform: scale(0.96);
}

.key-action {
  background: #e2e8f0;
  font-size: 20px;
}

/* ========================================== */
/* APP PRINCIPAL                              */
/* ========================================== */
.app-header {
  background-color: #1e3a8a;
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.header-info h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.badge-online {
  font-size: 12px;
  color: #4ade80;
  font-weight: 600;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.app-content {
  flex: 1;
  padding: 16px;
  padding-bottom: 90px; /* espacio para bottom nav */
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.section-title {
  margin-bottom: 16px;
}

.section-title h2 {
  font-size: 22px;
  font-weight: 800;
}

.section-title p {
  font-size: 14px;
  color: var(--text-muted);
}

/* Buscador */
.search-box input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: 14px;
  background: var(--card-bg);
  margin-bottom: 12px;
  outline: none;
}

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

/* Píldoras de filtro */
.filter-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.pill {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}

.pill.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Tarjetas de Facturas */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.invoice-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.invoice-card:active {
  transform: scale(0.99);
}

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

.client-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

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

.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-paid {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-pending {
  background: var(--color-pending-bg);
  color: var(--color-pending);
}

.badge-partial {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.card-amounts {
  display: flex;
  justify-content: space-between;
  background: #f1f5f9;
  padding: 10px 14px;
  border-radius: 12px;
}

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

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

.amount-box strong {
  font-size: 16px;
  font-weight: 700;
}

.debt-amount {
  color: var(--color-pending);
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-card-abono {
  background: var(--color-success);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

/* ========================================== */
/* FORMULARIO FÁCIL                           */
/* ========================================== */
.easy-form {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-main);
}

.form-group input, .form-group select {
  padding: 14px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: #fff;
  outline: none;
  font-family: inherit;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--primary-color);
}

.input-large {
  font-size: 26px !important;
  font-weight: 800;
  text-align: center;
  color: var(--color-success);
}

.info-card {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 12px 16px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 4px;
}

.highlight-pending {
  border-top: 1px solid #dbeafe;
  padding-top: 6px;
  margin-top: 4px;
  font-size: 16px;
  color: var(--color-pending);
}

/* Botones */
.btn-primary {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:active {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-main);
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.full-width {
  width: 100%;
}

.btn-xl {
  padding: 18px;
  font-size: 18px;
  background: var(--color-success);
}

.btn-xl:active {
  background: #166534;
}

/* ========================================== */
/* RESUMEN DE COMISIONES                      */
/* ========================================== */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-card {
  padding: 16px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
}

.card-paid {
  background: var(--color-success-bg);
  border: 1px solid #bbf7d0;
  color: var(--color-success);
}

.card-pending {
  background: var(--color-warning-bg);
  border: 1px solid #fed7aa;
  color: var(--color-warning);
}

.sum-label {
  font-size: 13px;
  font-weight: 600;
}

.sum-value {
  font-size: 22px;
  font-weight: 800;
  margin-top: 4px;
}

/* NAVEGACIÓN INFERIOR */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  width: 33%;
  height: 100%;
  cursor: pointer;
}

.nav-icon {
  font-size: 24px;
}

.nav-text {
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.nav-btn.active {
  color: var(--primary-color);
}

.nav-btn.active .nav-icon {
  transform: scale(1.15);
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  z-index: 200;
}

.modal-card {
  background: var(--card-bg);
  width: 100%;
  max-width: 550px;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 24px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

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

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

.modal-header h3 {
  font-size: 20px;
  font-weight: 800;
}

.btn-close {
  background: #f1f5f9;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.modal-success {
  border-radius: 24px;
  align-self: center;
  text-align: center;
  padding: 32px 24px;
  margin: 20px;
}

.success-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.loading-spinner {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-weight: 600;
}
