/* ==========================
   Root Variables
========================== */
:root {
  /* Colors */
  --bg: #011745;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #152033;
  --muted: #64748b;
  --line: #dbe3ef;

  --brand: #1d4ed8;
  --brand-strong: #2563eb;
  --brand-2: #0f766e;

  --danger: #b91c1c;
  --success: #0f8a5f;

  /* Effects */
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 18px rgba(37, 99, 235, 0.18);

  /* Radius */
  --radius-lg: 28px;
  --radius: 18px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  /* Spacing */
  --gap: 16px;
  --gap-sm: 10px;

  /* Transitions */
  --transition: all 0.2s ease;
}

/* ==========================
   Base Styles
========================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #eef4ff 0%, var(--bg) 55%, #eef2f7 100%);
}

/* ==========================
   Layout
========================== */
.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 18px 48px;
}

/* ==========================
   Hero Section
========================== */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, var(--brand) 55%, var(--brand-2) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
}

.hero p {
  margin: 0;
  max-width: 900px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.9);
}

/* ==========================
   Sections
========================== */
.section {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 227, 239, 0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(8px);
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gap-sm);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.section-header .hint {
  margin: 0;
  font-size: 0.94rem;
  color: var(--muted);
}

.form-instructions {
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  border: 1px solid #cfe0ff;
}

/* ==========================
   Grid System
========================== */
[class^="grid-"] {
  display: grid;
  gap: var(--gap);
}

.grid-1 { grid-template-columns: repeat(1, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

/* ==========================
   Cards
========================== */
.instruction-card,
.check-card,
.preview-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
}

.instruction-card {
  padding: 14px 16px;
}

.instruction-card strong {
  display: block;
  margin-bottom: 6px;
}

.instruction-card span {
  font-size: 0.94rem;
  color: var(--muted);
  line-height: 1.45;
}

.subtle-box {
  background: var(--panel-2);
  border: 1px dashed #cdd7e7;
  border-radius: var(--radius-md);
  padding: 14px;
}

/* ==========================
   Forms
========================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

.req {
  color: var(--danger);
  margin-left: 4px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  color: var(--text);
  transition: var(--transition);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(29, 78, 216, 0.65);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12);
}

:disabled {
  background: var(--panel-2);
  color: #94a3b8;
  cursor: not-allowed;
}

/* ==========================
   Toggles
========================== */
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
}

.toggle-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.toggle-btn:hover {
  transform: translateY(-1px);
}

.toggle-btn.active {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-soft);
}

/* ==========================
   Buttons
========================== */
.btn {
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

/* Add Member Buttons - Unified Style */
.add-member-btn {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.add-member-btn span {
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 600;
}

.add-member-btn.btn-secondary {
  background: #ffffff;
  border: 1.5px dashed #94a3b8;
  color: #475569;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.95rem;
}

.add-member-btn.btn-secondary:hover {
  background: #f8fafc;
  border-color: var(--brand);
  color: var(--brand);
}

/* ==========================
   Preview Boxes
========================== */
.preview-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.preview-box {
  width: 210px;
  height: 210px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
}

.preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-box.clickable,
.preview-box.signature {
  cursor: pointer;
  transition: var(--transition);
}

.preview-box.clickable:hover,
.preview-box.signature:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.25);
}

.placeholder-text {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.preview-box img + .placeholder-text {
  display: none;
}

/* Signature-specific preview */
.preview-box.signature {
  width: 240px;
  height: 100px;
  border-radius: 10px;
}

.preview-box.signature img {
  object-fit: contain;
  background: #fff;
}

/* ==========================
   Checkbox Grid
========================== */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--gap-sm);
}

.check-card {
  padding: 7px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.check-card input {
  position: absolute;
  opacity: 0;
}

.check-card div {
  font-size: 0.79rem;
  width: 100%;
}

.check-card:hover {
  border-color: rgba(29, 78, 216, 0.35);
  background: rgba(29, 78, 216, 0.04);
}

.check-card:active {
  transform: scale(0.97);
}

.check-card:has(input:checked),
.check-card.selected {
  background: #c0e7fc;
  border-color: rgba(29, 78, 216, 0.45);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.08);
}

/* ==========================
   Key Personnel Cards (Sponsor Form)
========================== */
.key-personnel-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-bottom: 20px;
}

.key-personnel-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  position: relative;
}

.key-personnel-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #eef2f6;
}

.key-personnel-card .card-title {
  font-weight: 600;
  font-size: 1.2rem;
  color: #1e293b;
}

.key-personnel-card .remove-card-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.3rem;
  padding: 4px 10px;
  border-radius: 30px;
  transition: all 0.2s;
  font-weight: bold;
}

.key-personnel-card .remove-card-btn:hover {
  background: #fee2e2;
  transform: scale(1.05);
}

.key-personnel-card .file-name {
  font-size: 0.75rem;
  color: #3b82f6;
  margin-top: 6px;
}

/* Omang/Passport Groups (Key Personnel) */
.omang-fields-group,
.passport-fields-group {
  transition: all 0.2s ease;
}

.omang-fields-group.hidden,
.passport-fields-group.hidden {
  display: none !important;
}

/* ==========================
   Executive Committee Cards
========================== */
.executive-members-section {
  margin-top: 24px;
  padding: 20px;
  background: #f9fafb;
  border-radius: 12px;
}

.executive-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 20px;
}

.executive-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: box-shadow 0.2s;
  position: relative;
}

.executive-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.executive-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.executive-card .card-title {
  font-weight: 600;
  font-size: 1.1rem;
  color: #1e293b;
}

.executive-card .remove-card-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.executive-card .remove-card-btn:hover {
  background: #fee2e2;
}

.executive-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

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

.executive-form-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #334155;
}

.executive-form-field label .req {
  color: #ef4444;
}

.executive-form-field input,
.executive-form-field select,
.executive-form-field textarea {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: border 0.2s;
}

.executive-form-field input:focus,
.executive-form-field select:focus,
.executive-form-field textarea:focus {
  outline: none;
  border-color: #4A90E2;
  box-shadow: 0 0 0 2px rgba(74,144,226,0.1);
}

.executive-form-field textarea {
  resize: vertical;
  min-height: 60px;
}

.file-input-wrapper input[type="file"] {
  padding: 6px 0;
}

.file-name {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 4px;
  word-break: break-all;
}

/* ==========================
   Group Member Tables
========================== */
.group-org-member-table-wrapper {
  overflow-x: auto;
}

.group-org-member-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.group-org-member-table thead tr {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}

.group-org-member-table th {
  padding: 12px 8px;
  text-align: left;
  font-weight: 600;
  color: #1e293b;
}

.group-org-member-table td {
  padding: 12px 8px;
}

.remove-row-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.remove-row-btn:hover {
  background: #fee2e2;
}

/* ==========================
   Utilities
========================== */
.hidden { display: none !important; }

.inline-note,
.file-meta {
  font-size: 0.92rem;
  color: var(--muted);
}

/* ==========================
   Alerts / Messages
========================== */
.error-summary {
  display: none;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

.error-summary.show { display: block; }

.mini-banner {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #f8fbff;
  border: 1px solid #dbe7ff;
  color: #334155;
}

/* ==========================
   Footer / Misc
========================== */
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.footer-note {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 18px;
}

.signature-line {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.auto-date {
  background: var(--panel-2);
  font-weight: 600;
}

.json-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  background: #eff6ff;
  color: var(--brand);
  border: 1px solid #dbeafe;
}

/* ==========================
   Responsive Design
========================== */
@media (max-width: 1024px) {
  .checkbox-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 980px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .instructions-grid,
  .signature-line {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
  
  .executive-form-grid {
    grid-template-columns: 1fr;
  }
  
  .executive-card {
    padding: 16px;
  }

  /* Mobile Card Layout for Tables */
  .group-org-member-table-wrapper {
    overflow-x: visible;
  }
  
  .group-org-member-table,
  .group-org-member-table thead,
  .group-org-member-table tbody,
  .group-org-member-table tr,
  .group-org-member-table td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  
  .group-org-member-table thead {
    display: none;
  }
  
  .group-org-member-table tbody tr {
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
  }
  
  .group-org-member-table td {
    display: flex;
    align-items: flex-start;
    padding: 8px 0 !important;
    border-bottom: 1px solid #f1f5f9;
    text-align: left !important;
    border: none;
  }
  
  .group-org-member-table td:last-of-type {
    border-bottom: none;
  }
  
  .group-org-member-table td:first-child {
    font-weight: 700;
    color: #1e293b;
    font-size: 1.1rem;
    padding-top: 0 !important;
  }
  
  .group-org-member-table td:first-child::before {
    content: "#";
    font-weight: 600;
    width: 40%;
    min-width: 120px;
    color: #64748b;
    font-size: 0.85rem;
  }
  
  /* Labels for Executive Table */
  #group_executive_table_container tr td:nth-child(2)::before { content: "ITR Number:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  #group_executive_table_container tr td:nth-child(3)::before { content: "First Name:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  #group_executive_table_container tr td:nth-child(4)::before { content: "Surname:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  #group_executive_table_container tr td:nth-child(5)::before { content: "Committee Role:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  #group_executive_table_container tr td:nth-child(6)::before { content: "Role in Group:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  #group_executive_table_container tr td:nth-child(7)::before { content: "Action:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  
  /* Labels for Ordinary Members Table */
  #group_members_table_container tr td:nth-child(2)::before { content: "ITR Number:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  #group_members_table_container tr td:nth-child(3)::before { content: "First Name:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  #group_members_table_container tr td:nth-child(4)::before { content: "Surname:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  #group_members_table_container tr td:nth-child(5)::before { content: "Role in Group:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  #group_members_table_container tr td:nth-child(6)::before { content: "Action:"; font-weight: 600; width: 40%; min-width: 120px; color: #64748b; }
  
  .group-org-member-table td input,
  .group-org-member-table td select {
    flex: 1;
    min-width: 0;
    width: auto;
  }
  
  .group-org-member-table td:last-child {
    justify-content: flex-end;
  }
  
  .group-org-member-table td:last-child .remove-row-btn {
    margin-left: auto;
  }
  
  .remove-row-btn {
    padding: 8px 16px !important;
    font-size: 22px !important;
    min-height: 44px;
    min-width: 44px;
  }
  
  .add-member-btn {
    width: 100%;
    justify-content: center;
    padding: 14px 20px !important;
    font-size: 1rem;
  }
}