/* =============================================
   CheckStub — Premium Design Layer
   Atmosphere, depth, motion, typography
   ============================================= */

/* --- Background Atmosphere --- */
body {
  background:
    radial-gradient(ellipse at 15% 50%, rgba(0, 176, 154, 0.045) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(99, 102, 241, 0.025) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(0, 176, 154, 0.025) 0%, transparent 45%),
    #f9fafb;
  min-height: 100vh;
}

/* Subtle grain texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.25;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

body > * { position: relative; z-index: 1; }

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes borderGlow {
  0%, 100% { border-color: rgba(0, 176, 154, 0.25); }
  50%      { border-color: rgba(0, 176, 154, 0.50); }
}

@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(0, 176, 154, 0.2); }
  70%  { box-shadow: 0 0 0 10px rgba(0, 176, 154, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 176, 154, 0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* Page entrance */
main {
  animation: fadeIn 0.4s ease-out;
}

/* Stagger utility classes */
.stagger-1 { animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both; }
.stagger-2 { animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both; }
.stagger-3 { animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.19s both; }
.stagger-4 { animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.26s both; }
.stagger-5 { animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.33s both; }
.stagger-6 { animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.40s both; }

/* --- Card System --- */
.card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 176, 154, 0.06);
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.03),
    0 4px 16px rgba(0, 0, 0, 0.03),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  padding: 1.5rem;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.25s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.04),
    0 8px 32px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(0, 176, 154, 0.10) inset;
  border-color: rgba(0, 176, 154, 0.12);
}

.card-header {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header::before {
  content: '';
  width: 3px;
  height: 14px;
  background: #00b09a;
  border-radius: 2px;
}

/* --- Upload Zone --- */
.upload-zone {
  position: relative;
  border: 2px dashed rgba(0, 176, 154, 0.25);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.upload-zone:hover,
.upload-zone:focus-visible {
  border-color: rgba(0, 176, 154, 0.50);
  background: rgba(240, 255, 254, 0.75);
  transform: translateY(-2px);
  box-shadow:
    0 4px 24px rgba(0, 176, 154, 0.08),
    0 0 0 4px rgba(0, 176, 154, 0.04);
}

.upload-zone:focus-visible {
  outline: none;
  box-shadow:
    0 4px 24px rgba(0, 176, 154, 0.08),
    0 0 0 3px rgba(0, 176, 154, 0.25);
}

.upload-zone--active {
  border-color: #00b09a;
  background: rgba(240, 255, 254, 0.85);
  animation: borderGlow 2s ease-in-out infinite;
  cursor: default;
}

.upload-zone--success {
  border: 2px solid #10b981;
  background: rgba(240, 253, 244, 0.75);
  cursor: pointer;
}

.upload-zone--success:hover {
  background: rgba(220, 252, 231, 0.85);
  border-color: #059669;
}

.upload-zone--error {
  border: 2px solid #ef4444;
  background: rgba(254, 242, 242, 0.75);
  cursor: pointer;
}

.upload-zone--error:hover {
  background: rgba(254, 226, 226, 0.85);
  border-color: #dc2626;
}

/* Upload icon */
.upload-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0, 176, 154, 0.08), rgba(0, 176, 154, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background 0.3s ease;
}

.upload-zone:hover .upload-icon {
  transform: translateY(-2px) scale(1.05);
  background: linear-gradient(135deg, rgba(0, 176, 154, 0.12), rgba(0, 176, 154, 0.22));
}

/* Upload zone content transition */
.upload-content {
  transition: opacity 0.2s ease;
}

.upload-content--fading {
  opacity: 0;
}

/* --- Table Enhancements --- */
.stubs-table-wrap {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 176, 154, 0.06);
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.02),
    0 4px 16px rgba(0, 0, 0, 0.02);
  overflow: hidden;
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

.stubs-table-wrap table {
  border-collapse: separate;
  border-spacing: 0;
}

.stubs-table-wrap thead {
  background: rgba(248, 250, 252, 0.9);
  backdrop-filter: blur(4px);
}

.stubs-table-wrap thead th {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-family: 'Inter', system-ui, sans-serif;
}

.stubs-table-wrap tbody tr {
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.stubs-table-wrap tbody tr:hover {
  background-color: rgba(0, 176, 154, 0.03) !important;
}

.stubs-table-wrap tbody tr:not(:last-child) td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

/* Row entrance stagger */
.stubs-table-wrap tbody tr {
  animation: fadeIn 0.3s ease-out both;
}
.stubs-table-wrap tbody tr:nth-child(1) { animation-delay: 0.02s; }
.stubs-table-wrap tbody tr:nth-child(2) { animation-delay: 0.04s; }
.stubs-table-wrap tbody tr:nth-child(3) { animation-delay: 0.06s; }
.stubs-table-wrap tbody tr:nth-child(4) { animation-delay: 0.08s; }
.stubs-table-wrap tbody tr:nth-child(5) { animation-delay: 0.10s; }
.stubs-table-wrap tbody tr:nth-child(n+6) { animation-delay: 0.12s; }

/* --- Financial Typography --- */
.amount-primary {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: #1f2937;
}

.amount-secondary {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-weight: 500;
  font-size: 0.875rem;
  color: #374151;
}

.amount-negative {
  color: #dc2626;
}

.amount-positive {
  color: #059669;
}

.amount-hero {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
  color: #111827;
}

.label-muted {
  font-size: 0.8125rem;
  color: #9ca3af;
  font-weight: 400;
}

/* --- Confidence Badge --- */
.confidence-badge {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-weight: 600;
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.confidence-high   { background: rgba(16, 185, 129, 0.10); color: #059669; }
.confidence-medium { background: rgba(245, 158, 11, 0.10); color: #d97706; }
.confidence-low    { background: rgba(239, 68, 68, 0.08);  color: #dc2626; }

/* --- Validation Checks --- */
.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.8125rem;
}

.check-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.check-pass {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.check-fail {
  background: rgba(239, 68, 68, 0.10);
  color: #dc2626;
}

/* --- Progress Bar Enhancement --- */
.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.75rem;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #00b09a, #2dd4bf);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

/* --- Spinner Enhancement --- */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 176, 154, 0.15);
  border-top-color: #00b09a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Filter Bar --- */
.filter-bar {
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.filter-bar select,
.filter-bar input[type="date"] {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-bar select:focus,
.filter-bar input[type="date"]:focus {
  border-color: rgba(0, 176, 154, 0.4);
  box-shadow: 0 0 0 3px rgba(0, 176, 154, 0.08);
  outline: none;
}

/* --- Detail Page Back Link --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #00b09a;
  text-decoration: none;
  padding: 6px 12px;
  margin: -6px -12px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.back-link:hover {
  background: rgba(0, 176, 154, 0.06);
  color: #008673;
}

/* --- Delete Button --- */
.delete-action {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.delete-btn {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.05);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.12);
  cursor: pointer;
  transition: all 0.2s ease;
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.25);
  color: #dc2626;
}

/* --- Load More Button --- */
.load-more-btn {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1.5rem;
  border-radius: 10px;
  background: rgba(0, 176, 154, 0.06);
  color: #00b09a;
  border: 1px solid rgba(0, 176, 154, 0.15);
  cursor: pointer;
  transition: all 0.2s ease;
}

.load-more-btn:hover {
  background: rgba(0, 176, 154, 0.12);
  border-color: rgba(0, 176, 154, 0.25);
  transform: translateY(-1px);
}

/* --- Extraction Info --- */
.extraction-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.75rem;
  color: #9ca3af;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.015);
  border-radius: 10px;
  margin-bottom: 1.5rem;
}

.extraction-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}
