/* ============================================================
   ImmAppeals — Professional Immigration Appeals Dashboard
   Shared stylesheet: style.css
   ============================================================ */

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

:root {
  --navy:        #1E293B;
  --navy-light:  #334155;
  --navy-dark:   #0F172A;
  --blue:        #D97706;
  --blue-light:  #F59E0B;
  --blue-pale:   #FEF3C7;
  --green:       #059669;
  --green-pale:  #d1fae5;
  --red:         #dc2626;
  --red-pale:    #fee2e2;
  --amber:       #d97706;
  --amber-pale:  #fef3c7;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-300:    #d1d5db;
  --gray-400:    #9ca3af;
  --gray-500:    #6b7280;
  --gray-600:    #4b5563;
  --gray-700:    #374151;
  --gray-800:    #1f2937;
  --white:       #ffffff;
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.05);
  --shadow:      0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius:      8px;
  --radius-lg:   12px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* --- Top Nav --- */
.topbar {
  background: var(--navy);
  border-bottom: 1px solid var(--navy-light);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--white);
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--blue);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--white);
}

.logo-text {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.topbar-link:hover {
  color: var(--white);
  background: rgba(255,255,255,0.08);
}

.topbar-link.active {
  color: var(--white);
  background: rgba(255,255,255,0.12);
}

/* --- Container --- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* --- Page Header --- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
}

.page-header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.25;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--blue);
  color: var(--navy-dark);
  border-color: var(--blue);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--blue-light);
  border-color: var(--blue-light);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-outline {
  background: transparent;
  color: var(--blue);
  border-color: var(--blue);
}
.btn-outline:hover {
  background: var(--blue-pale);
}

.btn-danger-outline {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.btn-danger-outline:hover {
  background: var(--red-pale);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Stat Cards --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

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

.stat-card.total::before   { background: var(--navy); }
.stat-card.running::before { background: var(--amber); }
.stat-card.done::before    { background: var(--green); }
.stat-card.errors::before  { background: var(--red); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card.total   .stat-value { color: var(--navy); }
.stat-card.running .stat-value { color: var(--amber); }
.stat-card.done    .stat-value { color: var(--green); }
.stat-card.errors  .stat-value { color: var(--red); }

/* --- Job Card --- */
.job-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.job-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--gray-300);
}

.job-card.deleted {
  opacity: 0.55;
}

.job-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.job-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--navy);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.job-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.badge-queued {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-running {
  background: var(--amber-pale);
  color: #92400e;
  animation: pulse-badge 2s ease-in-out infinite;
}

.badge-done {
  background: var(--green-pale);
  color: #065f46;
}

.badge-error {
  background: var(--red-pale);
  color: #991b1b;
}

.badge-circuit {
  background: var(--blue-pale);
  color: #1e40af;
}

.badge-source {
  background: var(--gray-100);
  color: var(--gray-600);
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* --- Job Info Row --- */
.job-info {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--gray-500);
  align-items: center;
}

.job-info-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.job-info-item svg {
  width: 13px;
  height: 13px;
  opacity: 0.6;
}

/* --- Progress Bar --- */
.progress-track {
  height: 4px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.75rem 0 0.4rem;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
  background: linear-gradient(90deg, var(--blue-light), var(--green));
}

.progress-fill.error {
  background: var(--red);
}

.step-text {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.step-text.error {
  color: var(--red);
}

/* --- Job Actions --- */
.job-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
  align-items: center;
}

/* --- Preview Box --- */
.preview-box {
  display: none;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 0.85rem;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--gray-700);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--gray-500);
}

.empty-icon {
  width: 56px;
  height: 56px;
  background: var(--gray-100);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.empty-icon svg {
  width: 28px;
  height: 28px;
  color: var(--gray-400);
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 1.25rem;
}

/* --- Deleted Section --- */
.deleted-section {
  margin-top: 2.5rem;
  display: none;
}

.deleted-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.deleted-header h2 {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.deleted-list {
  display: none;
}

/* --- Footer --- */
.site-footer {
  text-align: center;
  color: var(--gray-400);
  font-size: 0.78rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-200);
  line-height: 1.6;
}

/* ============================================================
   NEW JOB PAGE
   ============================================================ */

.form-container {
  max-width: 680px;
  margin: 0 auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
  transition: color 0.15s;
}

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

.back-link svg {
  width: 16px;
  height: 16px;
}

.form-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.form-card-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-100);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
}

.form-hint {
  font-weight: 400;
  color: var(--gray-400);
  font-size: 0.8rem;
  margin-left: 0.25rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-800);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--gray-400);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1.2rem;
  padding-right: 2.5rem;
}

.form-textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.6;
}

/* --- Drag-drop zone --- */
.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--blue);
  background: rgba(37, 99, 235, 0.03);
}

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

.drop-zone-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 0.75rem;
  color: var(--gray-400);
}

.drop-zone-text {
  font-size: 0.9rem;
  color: var(--gray-600);
}

.drop-zone-text strong {
  color: var(--blue);
}

.drop-zone-hint {
  font-size: 0.78rem;
  color: var(--gray-400);
  margin-top: 0.3rem;
}

.file-name-display {
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 500;
  margin-top: 0.5rem;
  min-height: 1.25rem;
}

/* --- OR divider --- */
.or-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: var(--gray-400);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* --- Submit area --- */
.submit-area {
  margin-top: 0.5rem;
}

.btn-submit {
  width: 100%;
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
}

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

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .container {
    padding: 1.25rem 1rem 2rem;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .job-top {
    flex-direction: column;
    gap: 0.5rem;
  }

  .job-title {
    white-space: normal;
  }

  .job-meta {
    align-self: flex-start;
  }

  .job-actions {
    flex-direction: column;
  }

  .job-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .form-card {
    padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr 1fr;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .topbar {
    padding: 0 1rem;
  }

  .logo-text {
    font-size: 1rem;
  }
}
