/* =========================================================================
   SRIAAN SPV AGREEMENT BUILDER - ENTERPRISE DESIGN SYSTEM
   ========================================================================= */

:root {
  /* Brand Palette */
  --primary-navy: #0F172A;
  --primary-blue: #1E40AF;
  --blue-accent: #3B82F6;
  --blue-soft: #EFF6FF;
  --green-solar: #10B981;
  --green-soft: #ECFDF5;
  --amber-warm: #F59E0B;
  --amber-soft: #FFFBEB;
  --red-alert: #EF4444;
  --red-soft: #FEF2F2;

  /* Surfaces & Text */
  --bg-app: #F8FAFC;
  --paper-white: #FFFFFF;
  --surface-muted: #F1F5F9;
  --ink-heading: #0F172A;
  --ink-body: #334155;
  --ink-muted: #64748B;
  --border-light: #E2E8F0;
  --border-strong: #CBD5E1;

  /* Form Highlight States */
  --state-complete: #10B981;
  --state-incomplete: #F59E0B;
  --state-invalid: #EF4444;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --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);
  --shadow-glow: 0 0 12px rgba(59, 130, 246, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  background-color: var(--bg-app);
  color: var(--ink-body);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-muted);
}

::selection {
  background: var(--blue-soft);
  color: var(--primary-blue);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* Application Shell Layout */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 70px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  height: 42px;
  width: auto;
}

.brand-badge {
  background: var(--blue-soft);
  color: var(--primary-blue);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-heading);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-blue), var(--green-solar));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

/* Main Layout Grid */
.app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
  background: var(--primary-navy);
  color: #F8FAFC;
  position: sticky;
  top: 70px;
  height: calc(100vh - 70px);
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
}

.seal-container {
  padding: 20px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 14px;
}

.seal-text-block h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.seal-text-block p {
  margin: 2px 0 0;
  font-size: 11px;
  color: #94A3B8;
  line-height: 1.3;
}

nav.stepnav {
  padding: 12px 10px;
  flex: 1;
}

.nav-group-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #64748B;
  padding: 14px 12px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: #94A3B8;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: 3px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), rgba(16, 185, 129, 0.1));
  border-color: rgba(59, 130, 246, 0.4);
  color: #FFFFFF;
  font-weight: 600;
}

.nav-item .num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #475569;
  color: #94A3B8;
}

.nav-item.active .num {
  border-color: var(--blue-accent);
  background: var(--blue-accent);
  color: white;
}

.nav-item.done .num {
  background: var(--green-solar);
  border-color: var(--green-solar);
  color: white;
}

.nav-item .lbl {
  flex: 1;
}

/* Main Content Area */
main.content {
  padding: 36px 48px 120px;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.topbar .eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue-accent);
  font-weight: 600;
  margin-bottom: 6px;
}

.topbar h2 {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--ink-heading);
  margin: 0 0 8px;
  line-height: 1.2;
}

.topbar .desc {
  font-size: 14px;
  color: var(--ink-muted);
  max-width: 620px;
  line-height: 1.5;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons System */
.btn {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--paper-white);
  color: var(--ink-heading);
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.btn:hover {
  background: var(--surface-muted);
  border-color: var(--ink-muted);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-blue), #1D4ED8);
  color: #FFFFFF;
  border-color: var(--primary-blue);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1D4ED8, #1E40AF);
  color: #FFFFFF;
  box-shadow: var(--shadow-glow);
}

.btn-success {
  background: linear-gradient(135deg, var(--green-solar), #059669);
  color: #FFFFFF;
  border-color: var(--green-solar);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  color: #FFFFFF;
}

.btn-danger {
  background: var(--paper-white);
  color: var(--red-alert);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: var(--red-soft);
  border-color: var(--red-alert);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Modern Dashboard Cards & Grids */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--paper-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--blue-accent), var(--green-solar));
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-card .val {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--ink-heading);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card .lbl {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.card {
  background: var(--paper-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 30px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card h3 {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-heading);
  margin: 0 0 6px;
}

.card .card-sub {
  font-size: 13.5px;
  color: var(--ink-muted);
  margin: 0 0 24px;
  line-height: 1.5;
}

/* Grids */
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

/* Form Design & Highlighted Field States */
.field {
  margin-bottom: 20px;
  position: relative;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-heading);
  margin-bottom: 8px;
}

.field label .req {
  color: var(--red-alert);
  margin-left: 2px;
}

.field label .opt {
  font-weight: 400;
  color: var(--ink-muted);
}

.field .hint {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.field .err {
  font-size: 12px;
  color: var(--red-alert);
  margin-top: 6px;
  display: none;
  font-weight: 500;
}

.field.has-error .err {
  display: block;
}

/* Inputs & Form Controls */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-white);
  font-size: 14px;
  color: var(--ink-heading);
  transition: var(--transition-fast);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Form Visual Highlight Rules (Requirement #7) */
/* Complete state: Green border */
.field.is-complete input,
.field.is-complete select,
.field.is-complete textarea {
  border-color: var(--state-complete) !important;
  background-color: #F0FDF4;
}

/* Incomplete / Required state: Orange border */
.field.is-incomplete input,
.field.is-incomplete select,
.field.is-incomplete textarea {
  border-color: var(--state-incomplete) !important;
  background-color: #FFFBEB;
}

/* Invalid / Error state: Red border */
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--state-invalid) !important;
  background-color: #FEF2F2;
}

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

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%2364748B'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.unit-input {
  position: relative;
}

.unit-input .unit-tag {
  position: absolute;
  right: 1.5px;
  top: 1.5px;
  bottom: 1.5px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--surface-muted);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-muted);
  border-left: 1.5px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.unit-input input {
  padding-right: 64px;
}

.radio-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding-top: 6px;
}

.radio-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.radio-opt input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-blue);
}

/* Drag and Drop File Upload Component */
.file-drop {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  background: var(--bg-app);
  font-size: 13px;
  color: var(--ink-muted);
  position: relative;
  transition: var(--transition-fast);
  cursor: pointer;
}

.file-drop:hover, .file-drop.drag-over {
  border-color: var(--blue-accent);
  background: var(--blue-soft);
}

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

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--paper-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  margin-top: 8px;
  box-shadow: var(--shadow-sm);
}

.file-chip .fname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: 500;
}

.file-chip img.thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* Dynamic Repeatable List Subrows */
.subrow {
  display: grid;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
  padding: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  position: relative;
}

.subrow .rm-row {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--red-alert);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.add-row-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-blue);
  background: var(--blue-soft);
  border: 1.5px dashed var(--blue-accent);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  width: 100%;
  margin-top: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.add-row-btn:hover {
  background: #DBEAFE;
}

/* Responsive Tables */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--paper-white);
  box-shadow: var(--shadow-sm);
}

.doc-list {
  width: 100%;
  border-collapse: collapse;
}

.doc-row {
  display: grid;
  grid-template-columns: 80px 1fr 280px;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}

.doc-row:last-child {
  border-bottom: none;
}

.doc-row:nth-child(even) {
  background: var(--bg-app);
}

.doc-row:hover {
  background: var(--blue-soft);
}

.doc-row .doc-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--primary-blue);
  font-weight: 700;
}

.doc-row .doc-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-heading);
}

.doc-row .doc-desc {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Bottom Progress Strip */
.progress-strip {
  position: sticky;
  bottom: 0;
  background: var(--paper-white);
  border-top: 1px solid var(--border-light);
  padding: 14px 48px;
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 30;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.progress-strip .bar-track {
  flex: 1;
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

.progress-strip .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-accent), var(--green-solar));
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-strip .pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-heading);
  width: 48px;
}

/* Toast Notifications */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  background: var(--primary-navy);
  color: #FFFFFF;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: 12px;
  align-items: center;
}

.toast.error {
  background: var(--red-alert);
}

.toast.success {
  background: var(--green-solar);
}

/* Printed Document Preview Paper Shell */
.preview-shell {
  background: #CBD5E1;
  padding: 32px;
  border-radius: var(--radius-md);
}

#docPreview {
  background: #FFFFFF;
  max-width: 820px;
  margin: 0 auto;
  padding: 64px;
  font-family: 'Fraunces', serif;
  color: #0F172A;
  font-size: 13px;
  line-height: 1.7;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

#docPreview h1.doctitle {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px;
}

#docPreview .doc-centersub {
  text-align: center;
  font-size: 13px;
  margin: 3px 0;
}

#docPreview h2.partheading {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  margin: 32px 0 12px;
  border-bottom: 2px solid #0F172A;
  padding-bottom: 6px;
}

#docPreview table.pv-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 12px;
}

#docPreview table.pv-table td,
#docPreview table.pv-table th {
  border: 1px solid #64748B;
  padding: 8px 12px;
}

#docPreview table.pv-table th {
  background: #F1F5F9;
}

#docPreview .blank {
  border-bottom: 1.5px solid #0F172A;
  padding: 0 4px;
  font-weight: 700;
}

#docPreview .blank.empty {
  color: var(--red-alert);
}

.section-panel {
  display: none;
}

.section-panel.active {
  display: block;
}
