/* shared/styles.css — SEAP Review Portal v2 Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── Custom Properties ──────────────────────────────────────────── */
:root {
  --red:         #DC2626;
  --red-dark:    #B91C1C;
  --red-light:   #FEE2E2;
  --blue:        #2563EB;
  --blue-light:  #DBEAFE;
  --green:       #059669;
  --green-light: #D1FAE5;
  --amber:       #D97706;
  --amber-light: #FEF3C7;
  --purple:      #7C3AED;
  --purple-light:#EDE9FE;
  --indigo:      #4F46E5;
  --indigo-light:#E0E7FF;
  --gray:        #6B7280;
  --gray-light:  #F3F4F6;
  --gray-200:    #E5E7EB;
  --gray-300:    #D1D5DB;
  --gray-400:    #9CA3AF;
  --gray-700:    #374151;
  --gray-800:    #1F2937;
  --gray-900:    #111827;
  --bg:          #F9FAFB;
  --white:       #FFFFFF;
  --shadow:      0 1px 3px rgba(0,0,0,0.10);
  --shadow-md:   0 4px 6px rgba(0,0,0,0.10);
  --shadow-lg:   0 10px 15px rgba(0,0,0,0.10);
  --radius:      8px;
  --radius-sm:   4px;
  --radius-lg:   12px;
}

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

html, body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--bg);
  min-width: 320px;
  /* iframe-safe: no fixed height on body */
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; }

p { margin-bottom: 12px; }
p:last-child { margin-bottom: 0; }

/* ─── Layout ─────────────────────────────────────────────────────── */
.portal-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-content {
  flex: 1;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Cycle Status Banner ────────────────────────────────────────── */
.cycle-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
}
.cycle-banner.open   { background: var(--green-light); color: #065F46; border-bottom: 1px solid #A7F3D0; }
.cycle-banner.closed { background: var(--amber-light); color: #92400E; border-bottom: 1px solid #FDE68A; }
.cycle-banner.unknown{ background: var(--gray-light);  color: var(--gray); border-bottom: 1px solid var(--gray-200); }
.cycle-banner .cycle-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cycle-banner.open   .cycle-dot { background: var(--green); }
.cycle-banner.closed .cycle-dot { background: var(--amber); }
.cycle-banner.unknown .cycle-dot { background: var(--gray-400); }

/* ─── Portal Header ──────────────────────────────────────────────── */
.portal-header {
  background: var(--white);
  border-bottom: 2px solid var(--gray-200);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}
.portal-header .portal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.portal-header .portal-title .logo-badge {
  background: var(--red);
  color: white;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}
.portal-header .portal-title h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}
.portal-header .header-meta {
  font-size: 12px;
  color: var(--gray);
}

/* ─── Tabs ───────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  background: var(--white);
  overflow-x: auto;
}
.tab {
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
}
.tab:hover { color: var(--gray-800); }
.tab.active {
  color: var(--red);
  border-bottom-color: var(--red);
  font-weight: 600;
}

.tab-panels { }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
}
.card-subtitle {
  font-size: 12px;
  color: var(--gray);
  margin-top: 2px;
}

/* Option cards (landing page) */
.option-card {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.option-card:hover {
  border-color: var(--red);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.option-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.option-card .option-icon {
  font-size: 40px;
  line-height: 1;
}
.option-card h2 { font-size: 18px; color: var(--gray-900); }
.option-card p  { font-size: 13px; color: var(--gray); margin: 0; }

/* ─── Stat Cards ─────────────────────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray);
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}
.stat-card .stat-sub {
  font-size: 11px;
  color: var(--gray);
  margin-top: 4px;
}

/* ─── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.badge-gray   { background: #F3F4F6; color: #374151; }
.badge-blue   { background: var(--blue-light); color: #1D4ED8; }
.badge-purple { background: var(--purple-light); color: #6D28D9; }
.badge-indigo { background: var(--indigo-light); color: #4338CA; }
.badge-green  { background: var(--green-light); color: #047857; }
.badge-amber  { background: var(--amber-light); color: #B45309; }
.badge-red    { background: var(--red-light); color: #B91C1C; }

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--red); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }

.btn-secondary { background: white; color: var(--gray-800); border: 1px solid var(--gray-300); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-light); }

.btn-blue { background: var(--blue); color: white; }
.btn-blue:hover:not(:disabled) { background: #1D4ED8; }

.btn-green { background: var(--green); color: white; }
.btn-green:hover:not(:disabled) { background: #047857; }

.btn-amber { background: var(--amber); color: white; }
.btn-amber:hover:not(:disabled) { background: #B45309; }

.btn-ghost { background: transparent; color: var(--gray); border: 1px solid transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--gray-light); color: var(--gray-800); }

.btn-danger { background: var(--red-light); color: var(--red-dark); border: 1px solid #FECACA; }
.btn-danger:hover:not(:disabled) { background: #FECACA; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }

/* ─── Forms ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray);
  margin-bottom: 5px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-error { color: var(--red); font-size: 11px; margin-top: 3px; }
.form-hint  { color: var(--gray); font-size: 11px; margin-top: 3px; }

input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  width: 100%;
  outline: none;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  color: var(--gray-800);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-light);
}
input.error, select.error, textarea.error {
  border-color: var(--red);
  box-shadow: 0 0 0 2px var(--red-light);
}
textarea { resize: vertical; min-height: 80px; }
input[type="checkbox"], input[type="radio"] { width: auto; }

.search-bar {
  position: relative;
  flex: 1;
}
.search-bar input { padding-left: 34px; }
.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  pointer-events: none;
}

/* Filter row */
.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-row select { width: auto; min-width: 120px; }

/* ─── Tables ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray);
  padding: 10px 14px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
  background: var(--gray-light);
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-light); }
tbody tr.clickable { cursor: pointer; }

/* ─── Modals ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.modal.modal-lg { max-width: 780px; }
.modal.modal-xl { max-width: 960px; }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray);
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--gray-800); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

/* ─── Progress Bar ───────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--gray-200);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--red);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-bar-fill.green  { background: var(--green); }
.progress-bar-fill.blue   { background: var(--blue); }
.progress-bar-fill.amber  { background: var(--amber); }

/* ─── Horizontal Bar Chart ───────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 40px;
  align-items: center;
  gap: 10px;
}
.bar-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  background: var(--gray-200);
  border-radius: 3px;
  height: 22px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  border-radius: 3px;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  transition: width 0.5s ease;
  min-width: 2px;
}
.bar-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  text-align: right;
}

/* ─── Toast Notifications ────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  max-width: 340px;
  animation: toast-in 0.25s ease;
  pointer-events: auto;
}
.toast.success { background: #ECFDF5; color: #047857; border: 1px solid #A7F3D0; }
.toast.error   { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.toast.info    { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.toast.warning { background: var(--amber-light); color: #B45309; border: 1px solid #FDE68A; }
.toast.fade-out { animation: toast-out 0.25s ease forwards; }

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

/* ─── Loading / Empty States ─────────────────────────────────────── */
.loading-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray);
}
.loading-spinner {
  display: inline-block;
  width: 28px; height: 28px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state h3 { color: var(--gray-700); margin-bottom: 6px; }

/* ─── Section Headers ────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
}

/* ─── Not Configured State ───────────────────────────────────────── */
.not-configured {
  background: var(--amber-light);
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  padding: 14px 18px;
  color: #92400E;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Detail Rows (key-value) ────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 16px;
  font-size: 13px;
}
.detail-label { color: var(--gray); font-weight: 500; }
.detail-value { color: var(--gray-800); }

/* ─── Collapsible ────────────────────────────────────────────────── */
.collapsible {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
}
.collapsible-header {
  padding: 12px 16px;
  background: var(--gray-light);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.collapsible-header:hover { background: var(--gray-200); }
.collapsible-body { padding: 16px; display: none; }
.collapsible.open .collapsible-body { display: block; }
.collapsible-arrow { transition: transform 0.2s; display: inline-block; }
.collapsible.open .collapsible-arrow { transform: rotate(180deg); }

/* ─── Tag Pills ──────────────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  background: var(--blue-light);
  color: #1D4ED8;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

/* ─── Wizard Steps ───────────────────────────────────────────────── */
.wizard-steps {
  display: flex;
  margin-bottom: 28px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.wizard-step {
  flex: 1;
  text-align: center;
  position: relative;
  min-width: 80px;
}
.wizard-step::before {
  content: '';
  position: absolute;
  top: 13px;
  left: 0; right: 0;
  height: 3px;
  background: var(--gray-200);
  z-index: 0;
}
.wizard-step:first-child::before { left: 50%; }
.wizard-step:last-child::before  { right: 50%; }
.wizard-step .step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  position: relative;
  z-index: 1;
}
.wizard-step.done   .step-num { background: var(--green); color: white; }
.wizard-step.active .step-num { background: var(--red); color: white; box-shadow: 0 0 0 3px var(--red-light); }
.wizard-step .step-label { font-size: 11px; color: var(--gray); margin-top: 5px; }
.wizard-step.active .step-label { color: var(--red); font-weight: 600; }
.wizard-step.done   .step-label { color: var(--green); }
.wizard-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

/* ─── Decision Panel ─────────────────────────────────────────────── */
.decision-panel {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  background: white;
}
.decision-panel .decision-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-content { padding: 12px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 100px 1fr 36px; }
  .detail-grid { grid-template-columns: 120px 1fr; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 400px) {
  .stat-cards { grid-template-columns: 1fr; }
  .tabs { flex-direction: column; }
  .tab { border-bottom: 1px solid var(--gray-200); border-left: 3px solid transparent; }
  .tab.active { border-left-color: var(--red); border-bottom-color: var(--gray-200); }
}

/* ─── Utility ────────────────────────────────────────────────────── */
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.flex  { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.text-sm  { font-size: 12px; }
.text-muted { color: var(--gray); }
.text-danger { color: var(--red); }
.text-success { color: var(--green); }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }
