/* ============================================================
   OPD Claim Adjudication — Design System
   Modern, premium glassmorphism design
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Colors — Plum-inspired palette */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(20, 20, 32, 0.7);
  --bg-card-hover: rgba(30, 30, 48, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-strong: rgba(255, 255, 255, 0.06);

  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #555568;

  --accent-primary: #7c5cfc;
  --accent-secondary: #a78bfa;
  --accent-glow: rgba(124, 92, 252, 0.25);

  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --success-border: rgba(34, 197, 94, 0.3);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --warning-border: rgba(245, 158, 11, 0.3);

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.3);

  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);
  --info-border: rgba(59, 130, 246, 0.3);

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Background Effects ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 20%, rgba(124, 92, 252, 0.08), transparent),
    radial-gradient(ellipse 500px 300px at 80% 80%, rgba(59, 130, 246, 0.06), transparent),
    radial-gradient(ellipse 400px 400px at 50% 50%, rgba(167, 139, 250, 0.04), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Header ── */
.app-header {
  text-align: center;
  margin-bottom: 48px;
}

.app-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--shadow-glow);
}

.app-title {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ── Glass Card ── */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-base);
}

.glass-card:hover {
  border-color: var(--border-hover);
}

/* ── Section Titles ── */
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .icon {
  font-size: 20px;
}

/* ── Form Controls ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input {
  background: var(--bg-glass-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* ── File Upload Dropzone ── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.upload-dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  background: var(--bg-glass);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.upload-dropzone:hover {
  border-color: var(--accent-primary);
  background: rgba(124, 92, 252, 0.05);
}

.upload-dropzone.drag-over {
  border-color: var(--accent-primary);
  background: rgba(124, 92, 252, 0.1);
  transform: scale(1.02);
}

.upload-dropzone.has-file {
  border-color: var(--success);
  border-style: solid;
  background: var(--success-bg);
}

.upload-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 28px;
  opacity: 0.6;
}

.upload-dropzone.has-file .upload-icon {
  opacity: 1;
}

.upload-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.upload-dropzone.has-file .upload-label {
  color: var(--success);
}

.upload-filename {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.upload-tag.required {
  border-color: var(--accent-primary);
  color: var(--accent-secondary);
  background: rgba(124, 92, 252, 0.08);
}

.upload-tag.optional {
  color: var(--text-muted);
}

/* ── Checkbox ── */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.checkbox-group input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg-glass);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.checkbox-group input[type="checkbox"]:checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-group input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
}

.checkbox-label {
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ── Submit Button ── */
.btn-submit {
  width: 100%;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  color: white;
  background: linear-gradient(135deg, var(--accent-primary), #6341e0);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-glow);
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 40px var(--accent-glow);
}

.btn-submit:active:not(:disabled) {
  transform: translateY(0);
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-reset {
  width: 100%;
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  background: var(--bg-glass-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  margin-top: 12px;
}

.btn-reset:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ── Processing Stepper ── */
.processing-overlay {
  display: none;
  margin-top: 32px;
  animation: fadeIn 0.3s ease;
}

.processing-overlay.visible {
  display: block;
}

.stepper {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 0;
  position: relative;
}

.step-indicator {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: all var(--transition-slow);
  position: relative;
  z-index: 2;
}

.step-indicator.pending {
  background: var(--bg-glass-strong);
  border: 2px solid var(--border);
  color: var(--text-muted);
}

.step-indicator.active {
  background: var(--accent-glow);
  border: 2px solid var(--accent-primary);
  color: var(--accent-secondary);
  box-shadow: 0 0 20px var(--accent-glow);
  animation: pulse 1.5s ease-in-out infinite;
}

.step-indicator.complete {
  background: var(--success-bg);
  border: 2px solid var(--success);
  color: var(--success);
}

.step-indicator.error {
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  color: var(--danger);
}

/* Connector line between steps */
.step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 54px;
  width: 2px;
  height: calc(100% - 28px);
  background: var(--border);
  z-index: 1;
  transition: background var(--transition-slow);
}

.step.done:not(:last-child)::before {
  background: var(--success);
}

.step-content {
  flex: 1;
  padding-top: 8px;
}

.step-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  transition: color var(--transition-base);
}

.step.pending .step-title {
  color: var(--text-muted);
}

.step-description {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Decision Card ── */
.decision-section {
  display: none;
  margin-top: 32px;
  animation: slideUp 0.5s ease;
}

.decision-section.visible {
  display: block;
}

.decision-card {
  position: relative;
  overflow: hidden;
}

.decision-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.decision-card.approved::before {
  background: linear-gradient(90deg, var(--success), #4ade80);
}

.decision-card.rejected::before {
  background: linear-gradient(90deg, var(--danger), #f87171);
}

.decision-card.manual_review::before {
  background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.decision-card.partial::before {
  background: linear-gradient(90deg, var(--info), #60a5fa);
}

/* Decision Header */
.decision-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.decision-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.decision-badge.approved {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.decision-badge.rejected {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.decision-badge.manual_review {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

.decision-badge.partial {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info);
}

.claim-id {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Stats Row */
.decision-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.stat-box {
  background: var(--bg-glass-strong);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
}

.stat-value.amount {
  background: linear-gradient(135deg, var(--success), #4ade80);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-value.confidence {
  color: var(--accent-secondary);
}

.stat-value.checks-count {
  color: var(--text-primary);
}

/* Rule Checks Grid — Enhanced Rule Trace */
.checks-section {
  margin-bottom: 24px;
}

.checks-grid {
  display: grid;
  gap: 8px;
}

.check-item.trace-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  font-size: 13px;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.check-item.trace-card:hover {
  background: var(--bg-glass-strong);
}

.check-item.trace-card.fail {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.check-item.trace-card.warn {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}

.check-row-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.check-icon.pass {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.check-icon.fail {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.check-icon.warn {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

.check-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-glass-strong);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.check-name {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.check-status-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.check-status-badge.pass {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.check-status-badge.fail {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.check-status-badge.warn {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

/* Trace Expected / Actual */
.trace-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  margin-left: 32px;
}

.trace-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.trace-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.trace-value {
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

.trace-value.pass {
  color: var(--success);
}

.trace-value.fail {
  color: var(--danger);
}

.trace-value.warn {
  color: var(--warning);
}

.check-detail-text {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: 32px;
  line-height: 1.5;
}

.check-detail {
  color: var(--text-secondary);
  font-size: 12px;
  flex: 1;
}

/* Deductions */
.deductions-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.deduction-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.deduction-value {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* Notes */
.notes-box {
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-primary);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Rejection Reasons */
.rejection-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.rejection-tag {
  padding: 4px 12px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--danger);
}

/* Extracted Data Preview */
.extracted-preview {
  margin-top: 24px;
}

.extracted-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-sans);
  transition: color var(--transition-fast);
}

.extracted-toggle:hover {
  color: var(--text-primary);
}

.extracted-grid {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.extracted-grid.visible {
  display: grid;
}

.extracted-item {
  font-size: 13px;
}

.extracted-key {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.extracted-value {
  color: var(--text-primary);
  font-weight: 500;
  margin-top: 2px;
}

/* ── Error Box ── */
.error-box {
  display: none;
  margin-top: 20px;
  padding: 18px 20px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: 14px;
  animation: fadeIn 0.3s ease;
}

.error-box.visible {
  display: block;
}

.error-title {
  font-weight: 600;
  margin-bottom: 4px;
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 10px var(--accent-glow); }
  50% { box-shadow: 0 0 25px var(--accent-glow); }
}

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

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

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-container {
    padding: 24px 16px 60px;
  }

  .upload-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .decision-stats {
    grid-template-columns: 1fr;
  }

  .deductions-section {
    grid-template-columns: 1fr;
  }

  .extracted-grid {
    grid-template-columns: 1fr;
  }

  .decision-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}
