/*
 * Contabilidad Congregación — Design System
 * Tailwind CDN handles utility classes; this file owns the soul.
 */

/* ───────────────────── Color Tokens ───────────────────── */
:root {
  /* Primary — deep teal */
  --color-primary-50:  #effcf6;
  --color-primary-100: #d0f7e5;
  --color-primary-200: #a4eed0;
  --color-primary-300: #6adeb5;
  --color-primary-400: #35c896;
  --color-primary-500: #14a87a;
  --color-primary-600: #098862;
  --color-primary-700: #076d51;
  --color-primary-800: #085641;
  --color-primary-900: #074736;
  --color-primary-950: #032820;

  /* Neutral — warm stone (not cold slate) */
  --color-neutral-50:  #fafaf9;
  --color-neutral-100: #f5f5f4;
  --color-neutral-200: #e7e5e4;
  --color-neutral-300: #d6d3d1;
  --color-neutral-400: #a8a29e;
  --color-neutral-500: #78716c;
  --color-neutral-600: #57534e;
  --color-neutral-700: #44403c;
  --color-neutral-800: #292524;
  --color-neutral-900: #1c1917;
  --color-neutral-950: #0c0a09;

  /* Accent — warm amber */
  --color-accent-400: #fbbf24;
  --color-accent-500: #f59e0b;
  --color-accent-600: #d97706;

  /* Semantic */
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger:  #dc2626;
  --color-info:    #0284c7;

  /* Surface & text */
  --surface-page:   var(--color-neutral-50);
  --surface-card:   #ffffff;
  --surface-raised: #ffffff;
  --text-primary:   var(--color-neutral-900);
  --text-secondary: var(--color-neutral-500);
  --text-muted:     var(--color-neutral-400);
  --border-default: var(--color-neutral-200);
  --border-subtle:  var(--color-neutral-100);

  /* Shadows */
  --shadow-sm:  0 1px 2px 0 rgb(0 0 0 / .04);
  --shadow-md:  0 4px 6px -1px rgb(0 0 0 / .06), 0 2px 4px -2px rgb(0 0 0 / .04);
  --shadow-lg:  0 10px 15px -3px rgb(0 0 0 / .07), 0 4px 6px -4px rgb(0 0 0 / .04);
  --shadow-xl:  0 20px 25px -5px rgb(0 0 0 / .08), 0 8px 10px -6px rgb(0 0 0 / .04);

  /* Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;

  /* Transition */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

/* ───────────────────── Base ───────────────────── */
body {
  background: var(--surface-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ───────────────────── Page-load animation ───────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}

.animate-fade-in {
  animation: fadeIn var(--duration-normal) ease both;
}

.animate-slide-down {
  animation: slideDown var(--duration-normal) var(--ease-out) both;
}

/* Staggered children */
.stagger-children > * {
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }

/* ───────────────────── Navbar ───────────────────── */
.app-navbar {
  background: var(--color-neutral-950);
  border-bottom: 1px solid rgb(255 255 255 / .06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-navbar .nav-link {
  position: relative;
  color: rgb(255 255 255 / .6);
  transition: color var(--duration-normal) var(--ease-out);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}

.app-navbar .nav-link:hover {
  color: rgb(255 255 255 / .95);
  background: rgb(255 255 255 / .07);
}

.app-navbar .nav-link::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--color-primary-400);
  transition: width var(--duration-normal) var(--ease-out), left var(--duration-normal) var(--ease-out);
  border-radius: 1px;
}

.app-navbar .nav-link:hover::after {
  width: 60%;
  left: 20%;
}

.app-navbar .nav-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.app-navbar .nav-brand .brand-icon {
  width: 1.75rem;
  height: 1.75rem;
  background: linear-gradient(135deg, var(--color-primary-400), var(--color-primary-600));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
}

.nav-user-section {
  border-left: 1px solid rgb(255 255 255 / .1);
  padding-left: 0.75rem;
  margin-left: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.nav-logout-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgb(255 255 255 / .7);
  background: rgb(255 255 255 / .08);
  border: 1px solid rgb(255 255 255 / .1);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) ease;
  cursor: pointer;
}

.nav-logout-btn:hover {
  background: rgb(255 255 255 / .14);
  color: #fff;
  border-color: rgb(255 255 255 / .2);
}

/* ───────────────────── Cards ───────────────────── */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-interactive:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--color-neutral-50);
}

.card-header h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-neutral-600);
  letter-spacing: 0.02em;
}

.card-body {
  padding: 1.25rem;
}

/* ───────────────────── Tables ───────────────────── */
.data-table {
  width: 100%;
  font-size: 0.875rem;
}

.data-table thead tr {
  border-bottom: 2px solid var(--border-default);
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.data-table td {
  padding: 0.875rem 1rem;
  color: var(--color-neutral-700);
  vertical-align: middle;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--duration-fast) ease;
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--color-neutral-50);
}

.data-table tfoot tr {
  background: var(--color-neutral-50);
  border-top: 2px solid var(--border-default);
}

.data-table tfoot th {
  font-size: 0.8125rem;
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: 0;
}

/* ───────────────────── Badges ───────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-pending::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  animation: pulse-dot 2s ease-in-out infinite;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-success::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.badge-neutral {
  background: var(--color-neutral-100);
  color: var(--color-neutral-700);
  border: 1px solid var(--color-neutral-200);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ───────────────────── Buttons ───────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5625rem 1.125rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  border: none;
}

.btn-primary {
  background: var(--color-primary-600);
  color: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / .08), inset 0 1px 0 rgb(255 255 255 / .1);
}

.btn-primary:hover {
  background: var(--color-primary-700);
  box-shadow: 0 2px 4px rgb(0 0 0 / .12), inset 0 1px 0 rgb(255 255 255 / .1);
  transform: translateY(-0.5px);
}

.btn-dark {
  background: var(--color-neutral-900);
  color: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / .08);
}

.btn-dark:hover {
  background: var(--color-neutral-800);
  box-shadow: 0 2px 4px rgb(0 0 0 / .12);
  transform: translateY(-0.5px);
}

.btn-outline {
  background: var(--surface-card);
  color: var(--color-neutral-700);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
  background: var(--color-neutral-50);
  border-color: var(--color-neutral-300);
  box-shadow: var(--shadow-md);
  transform: translateY(-0.5px);
}

.btn-ghost {
  background: transparent;
  color: var(--color-neutral-600);
  padding: 0.375rem 0.75rem;
}

.btn-ghost:hover {
  background: var(--color-neutral-100);
  color: var(--color-neutral-900);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--color-danger);
  padding: 0.375rem 0.75rem;
}

.btn-danger-ghost:hover {
  background: #fef2f2;
  color: #b91c1c;
}

.btn-lg {
  padding: 0.6875rem 1.5rem;
  font-size: 0.875rem;
}

/* ───────────────────── Form Inputs ───────────────────── */
.form-input {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast) ease,
              box-shadow var(--duration-fast) ease;
  outline: none;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:focus {
  border-color: var(--color-primary-400);
  box-shadow: 0 0 0 3px rgb(20 168 122 / .12);
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-neutral-700);
  margin-bottom: 0.375rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--color-danger);
  margin-top: 0.25rem;
}

/* ───────────────────── Flash / Alert ───────────────────── */
.flash-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  line-height: 1.5;
  border-left: 3px solid;
  animation: slideDown var(--duration-normal) var(--ease-out) both;
}

.flash-alert-success {
  background: #f0fdf4;
  color: #166534;
  border-left-color: var(--color-success);
}

.flash-alert-error {
  background: #fef2f2;
  color: #991b1b;
  border-left-color: var(--color-danger);
}

.flash-alert-info {
  background: #f0f9ff;
  color: #075985;
  border-left-color: var(--color-info);
}

.flash-alert-warning {
  background: #fffbeb;
  color: #92400e;
  border-left-color: var(--color-warning);
}

/* ───────────────────── Pagination ───────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-neutral-700);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) ease;
  text-decoration: none;
}

.pagination-btn:hover {
  background: var(--color-neutral-50);
  border-color: var(--color-neutral-300);
  box-shadow: var(--shadow-sm);
}

.pagination-info {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ───────────────────── Section headers ───────────────────── */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ───────────────────── Detail / Definition list ───────────────────── */
.detail-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-value {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* ───────────────────── Monetary column ───────────────────── */
.monto {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ───────────────────── Back links ───────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--duration-fast) ease;
  text-decoration: none;
}

.back-link:hover {
  color: var(--text-primary);
}

/* ───────────────────── Action links (table rows) ───────────────────── */
.action-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-neutral-500);
  transition: color var(--duration-fast) ease;
  text-decoration: none;
}

.action-link:hover {
  color: var(--color-primary-700);
}

.action-link-danger {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-danger);
  transition: color var(--duration-fast) ease;
  background: none;
  border: none;
  cursor: pointer;
}

.action-link-danger:hover {
  color: #b91c1c;
}

/* ───────────────────── Empty state ───────────────────── */
.empty-state {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.empty-state a {
  color: var(--color-primary-700);
  font-weight: 600;
  text-decoration: none;
}

.empty-state a:hover {
  text-decoration: underline;
}

/* ───────────────────── Info banner ───────────────────── */
.info-banner {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  line-height: 1.5;
  border: 1px solid;
}

.info-banner-warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.info-banner-warning a {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ───────────────────── Total display box ───────────────────── */
.total-display {
  background: var(--color-neutral-50);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
}

.total-display p {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ───────────────────── Status badges (legacy for PDF/print) ───────────────────── */
.estado-pendiente  { color: #b45309; font-weight: 600; }
.estado-depositado { color: #15803d; font-weight: 600; }
.estado-pagado     { color: #15803d; font-weight: 600; }

/* ───────────────────── Utility ───────────────────── */
[hidden] { display: none !important; }

/* Subtle dividers */
.dot-divider {
  color: var(--color-neutral-300);
  user-select: none;
}

/* Scrollbar refinement */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-neutral-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-neutral-400); }

/* Focus ring for accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary-400);
  outline-offset: 2px;
}

/* Smooth scroll */
html { scroll-behavior: smooth; }

/* Selection color */
::selection {
  background: var(--color-primary-200);
  color: var(--color-primary-950);
}
