/* ============================================================
   FCC Comment Summary Generator — Modern Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary: #3A9DC2;
  --primary-hover: #2A87AA;
  --primary-light: #E8F5FB;
  --primary-mid: #A8D8EC;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --border-focus: #7EC8E3;
  --bg: #F8FAFC;
  --white: #FFFFFF;
  --success: #059669;
  --success-bg: #ECFDF5;
  --success-border: #A7F3D0;
  --error: #DC2626;
  --error-bg: #FEF2F2;
  --error-border: #FECACA;
  --warning: #D97706;
  --card-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --radius: 12px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ================================================================
   HEADER
   ================================================================ */
header {
  background: #0F172A;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 5px 10px;
  border-radius: 6px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.header-title {
  font-size: 15px;
  font-weight: 600;
  color: #F1F5F9;
  letter-spacing: -.01em;
}
.header-sep { color: rgba(255,255,255,.2); margin: 0 2px; }
.header-sub {
  font-size: 13px;
  color: rgba(255,255,255,.45);
}
.header-spacer { flex: 1; }
.header-step {
  font-size: 12px;
  color: rgba(255,255,255,.4);
  font-weight: 500;
}

/* ================================================================
   MAIN
   ================================================================ */
main {
  max-width: 960px;
  margin: 40px auto;
  padding: 0 24px;
  flex: 1;
  width: 100%;
}

/* ================================================================
   HERO (index page only)
   ================================================================ */
.page-hero {
  margin-bottom: 32px;
}
.page-hero h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 8px;
}
.page-hero p {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 540px;
}

/* ================================================================
   CARD
   ================================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--card-shadow);
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.card-icon {
  width: 36px;
  height: 36px;
  background: var(--primary-light);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}
.card-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ================================================================
   FORM FIELDS
   ================================================================ */
.fields { display: flex; flex-direction: column; gap: 20px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.required { color: var(--error); }
.field-hint { font-size: 12px; color: var(--text-muted); }

input[type="text"],
input[type="date"] {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input[type="text"]:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input[type="text"]::placeholder { color: var(--text-muted); }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; }

/* ================================================================
   FILING TYPE PILLS
   ================================================================ */
.pill-group { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.pill-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  background: var(--white);
}
.pill-label:hover {
  border-color: var(--primary-mid);
  background: var(--primary-light);
  color: var(--primary);
}
.pill-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.pill-label.checked {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.pill-check { font-size: 11px; display: none; }
.pill-label.checked .pill-check { display: inline; }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 1px 3px rgba(37,99,235,.25);
  letter-spacing: -.01em;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled {
  opacity: .65;
  cursor: not-allowed;
  transform: none;
}
.btn-primary.btn-lg { padding: 14px 32px; font-size: 15px; border-radius: 10px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--white);
  color: var(--text);
  border: 1.5px solid var(--border);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: var(--bg); border-color: #CBD5E1; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-ghost:hover { text-decoration: underline; }

/* ================================================================
   FORM FOOTER
   ================================================================ */
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.form-note { font-size: 12px; color: var(--text-muted); }

/* ================================================================
   ALERTS
   ================================================================ */
.alert {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-error  { background: var(--error-bg);   border: 1px solid var(--error-border);   color: var(--error); }
.alert-success{ background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }
.alert-error ul  { margin: 6px 0 0 16px; }
.alert-error li  { margin-bottom: 3px; }

/* ================================================================
   HOW IT WORKS ROW
   ================================================================ */
.how-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 4px;
}
.how-step {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.how-num {
  width: 26px;
  height: 26px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.how-step p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ================================================================
   SELECT PAGE — Filing list
   ================================================================ */
.select-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-mid);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
}

.select-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.select-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.select-count span { color: var(--primary); }

.filing-list { display: flex; flex-direction: column; gap: 8px; }

.filing-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .1s;
  user-select: none;
}
.filing-row:hover {
  border-color: var(--primary-mid);
  background: var(--primary-light);
}
.filing-row.selected {
  border-color: var(--primary);
  background: #EFF6FF;
  box-shadow: 0 0 0 2px rgba(37,99,235,.08);
}
.filing-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.filing-info { flex: 1; min-width: 0; }
.filing-entity {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filing-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.filing-date { font-size: 12px; color: var(--text-muted); }
.filing-type-badge {
  font-size: 11px;
  font-weight: 600;
  background: #F1F5F9;
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.filing-docs { font-size: 12px; color: var(--text-muted); }
.filing-doc-name {
  display: inline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.cap-warning {
  background: #fff8e6;
  border: 1px solid #f0c040;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  color: #7a5500;
  margin-bottom: 20px;
  line-height: 1.5;
}

.no-filings {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.no-filings p { font-size: 15px; }
.no-filings a { color: var(--primary); text-decoration: none; }
.no-filings a:hover { text-decoration: underline; }

/* ================================================================
   PROGRESS PAGE
   ================================================================ */
.progress-container {
  max-width: 540px;
  margin: 0 auto;
}

.progress-card {
  text-align: center;
  padding: 52px 40px 40px;
}

/* Ring spinner */
.ring-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  margin: 0 auto 28px;
  position: relative;
}
@keyframes ring-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.ring-spinner {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 5px solid #E2E8F0;
  border-top-color: var(--primary);
  animation: ring-spin 0.85s linear infinite;
  position: absolute;
  top: 0; left: 0;
}
.ring-icon {
  font-size: 32px;
  position: relative;
  z-index: 1;
  display: none;
}

/* Done state */
.ring-wrap.done .ring-spinner { display: none; }
.ring-wrap.done .ring-icon { display: block; }
.ring-wrap.done .ring-bg {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--success-bg);
  border: 5px solid var(--success-border);
  position: absolute;
  top: 0; left: 0;
}

/* Error state */
.ring-wrap.error-state .ring-spinner { display: none; }
.ring-wrap.error-state .ring-icon { display: block; }
.ring-wrap.error-state .ring-bg {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--error-bg);
  border: 5px solid var(--error-border);
  position: absolute;
  top: 0; left: 0;
}

.progress-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 8px;
}
.progress-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* Download section */
.download-section { margin-top: 4px; }
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--success);
  color: #fff;
  border: none;
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
  box-shadow: 0 2px 8px rgba(5,150,105,.25);
}
.btn-download:hover { background: #047857; }

.new-search-link {
  display: block;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}
.new-search-link:hover { color: var(--primary); }

/* Details toggle */
.details-toggle { margin-top: 24px; text-align: center; }
.btn-details {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
}
.btn-details:hover {
  background: var(--bg);
  border-color: #CBD5E1;
  color: var(--text);
}
.details-arrow { font-size: 10px; transition: transform .2s; }
.details-arrow.open { transform: rotate(180deg); }

.details-panel {
  margin-top: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.detail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.detail-item:last-child { border-bottom: none; }
.detail-status {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}
.detail-status.pending { background: #F1F5F9; color: var(--text-muted); }
.detail-status.running { background: var(--primary-light); color: var(--primary); }
.detail-status.done    { background: var(--success-bg); color: var(--success); }
.detail-status.error   { background: var(--error-bg); color: var(--error); }
.detail-name { flex: 1; color: var(--text-secondary); font-weight: 500; }
.detail-name.active { color: var(--text); }
.detail-value { font-size: 12px; color: var(--text-muted); text-align: right; }
.detail-value.done { color: var(--success); }
.detail-value.error { color: var(--error); }

/* Failed filings list inside the details panel */
.failed-filings-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.failed-filing-item {
  padding: 8px 18px 8px 50px;
  font-size: 12px;
  color: var(--error);
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
  word-break: break-word;
}
.failed-filing-item:last-child { border-bottom: none; }

/* Detail spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.mini-spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--primary-mid);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ================================================================
   SHARED UTILITIES
   ================================================================ */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 20px;
  transition: color .15s;
}
.page-back:hover { color: var(--text); }

/* ================================================================
   SEARCH OVERLAY
   ================================================================ */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-overlay-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  padding: 44px 48px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.search-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--primary-mid);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.search-overlay-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.search-overlay-msg {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* ================================================================
   FOOTER
   ================================================================ */
footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ================================================================
   UPLOAD WARNING BANNER
   ================================================================ */
.upload-warning {
  background: #FFF7ED;
  border: 1.5px solid #FB923C;
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 28px;
}
.upload-warning-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.upload-warning-body { font-size: 13px; color: #7C2D12; line-height: 1.55; }
.upload-warning-body strong { color: #9A3412; font-weight: 700; }

/* ================================================================
   OR DIVIDER
   ================================================================ */
.or-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 36px 0 28px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.or-divider::before, .or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ================================================================
   DRAG-AND-DROP UPLOAD
   ================================================================ */
.drop-zone {
  border: 2px dashed #CBD5E1;
  border-radius: 10px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
  margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.drop-zone-icon { font-size: 32px; margin-bottom: 10px; }
.drop-zone-text { font-size: 14px; color: var(--text-secondary); }
.drop-zone-text strong { color: var(--primary); cursor: pointer; }
.drop-zone-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ── Uploaded file list ── */
.upload-file-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 20px; }
.upload-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  transition: box-shadow .12s, opacity .12s;
}
.upload-file-item.drag-over-above { border-top: 2px solid #2563EB; }
.upload-file-item.drag-over-below { border-bottom: 2px solid #2563EB; }
.upload-file-item.dragging { opacity: .4; }
.upload-drag-handle {
  cursor: grab; flex-shrink: 0; color: #94A3B8; font-size: 15px;
  line-height: 1; padding: 0 2px; user-select: none;
}
.upload-drag-handle:active { cursor: grabbing; }
.upload-file-icon { font-size: 15px; flex-shrink: 0; }
.upload-file-name { flex: 0 1 auto; color: var(--text); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.upload-filer-name {
  flex: 1; min-width: 100px;
  font-size: 13px; color: var(--text); font-weight: 500;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; outline: none; transition: border-color .12s;
}
.upload-filer-name:focus { border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.upload-file-size { color: var(--text-muted); font-size: 12px; flex-shrink: 0; white-space: nowrap; }
.upload-file-remove {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 18px; padding: 0 2px;
  line-height: 1; flex-shrink: 0; transition: color .12s;
}
.upload-file-remove:hover { color: var(--error); }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 640px) {
  main { margin: 24px auto; }
  .card { padding: 22px 20px; }
  .field-grid { grid-template-columns: 1fr; }
  .how-row { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .btn-primary.btn-lg, .btn-primary { width: 100%; }
  .header-sub { display: none; }
  .progress-card { padding: 40px 24px 32px; }
}
