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

:root {
  --ids-blue:       #1A3A5C;
  --ids-blue-mid:   #2C5F8A;
  --ids-blue-light: #4A7BA8;
  --ids-accent:     #0099CC;
  --ids-green:      #28A745;
  --ids-yellow:     #FFC107;
  --ids-red:        #DC3545;
  --ids-gray-50:    #F8F9FA;
  --ids-gray-100:   #E9ECEF;
  --ids-gray-200:   #DEE2E6;
  --ids-gray-500:   #6C757D;
  --ids-gray-700:   #495057;
  --ids-gray-900:   #212529;
  --sidebar-width:  270px;
  --header-height:  60px;
  --radius:         6px;
  --shadow:         0 2px 8px rgba(0,0,0,.12);
  --font:           'Segoe UI', Arial, sans-serif;
}

html, body { height: 100%; font-family: var(--font); color: var(--ids-gray-900); background: var(--ids-gray-50); }

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

/* ── Login Page ───────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--ids-blue) 0%, var(--ids-blue-mid) 100%);
}

.login-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  width: 420px;
  max-width: 95vw;
  padding: 48px 40px 40px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--ids-blue);
  letter-spacing: .5px;
}

.login-logo p {
  font-size: 13px;
  color: var(--ids-gray-500);
  margin-top: 4px;
}

.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--ids-blue);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.login-logo .logo-icon svg { fill: #fff; width: 36px; height: 36px; }

/* ── Form Controls ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ids-gray-700);
  margin-bottom: 5px;
}

label .required { color: var(--ids-red); margin-left: 2px; }
label .hint-icon { cursor: pointer; color: var(--ids-gray-500); font-style: normal; font-weight: 400; margin-left: 4px; font-size: 12px; }

input[type=text],
input[type=email],
input[type=password],
input[type=tel],
input[type=url],
input[type=number],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--ids-gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--ids-gray-900);
  background: #fff;
  transition: border-color .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--ids-accent);
  box-shadow: 0 0 0 3px rgba(0,153,204,.15);
}

input.error, select.error, textarea.error {
  border-color: var(--ids-red);
}

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

select { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row.three { grid-template-columns: 1fr 1fr 1fr; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .1s;
  text-decoration: none;
}

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

.btn-primary   { background: var(--ids-blue);      color: #fff; }
.btn-primary:hover   { background: var(--ids-blue-mid); }
.btn-secondary { background: var(--ids-gray-100);  color: var(--ids-gray-700); border: 1px solid var(--ids-gray-200); }
.btn-secondary:hover { background: var(--ids-gray-200); }
.btn-success   { background: var(--ids-green);     color: #fff; }
.btn-success:hover   { background: #218838; }
.btn-danger    { background: var(--ids-red);       color: #fff; }
.btn-danger:hover    { background: #c82333; }
.btn-outline   { background: transparent; color: var(--ids-blue); border: 1.5px solid var(--ids-blue); }
.btn-outline:hover   { background: var(--ids-blue); color: #fff; }
.btn-sm        { padding: 5px 12px; font-size: 12px; }
.btn-lg        { padding: 12px 28px; font-size: 16px; }
.btn:disabled  { opacity: .55; cursor: not-allowed; }
.btn-block     { width: 100%; justify-content: center; }

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

.portal-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--ids-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.portal-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
}

.portal-header .brand span { opacity: .7; font-weight: 400; font-size: 14px; }

.portal-header .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}

.portal-header .header-right a {
  color: rgba(255,255,255,.8);
  text-decoration: none;
}

.portal-header .header-right a:hover { color: #fff; }

.portal-body {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--ids-gray-200);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-progress {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--ids-gray-100);
}

.sidebar-progress p {
  font-size: 12px;
  color: var(--ids-gray-500);
  margin-bottom: 7px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.progress-bar {
  height: 8px;
  background: var(--ids-gray-100);
  border-radius: 99px;
  overflow: hidden;
}

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

.progress-text {
  font-size: 12px;
  color: var(--ids-gray-500);
  margin-top: 5px;
  display: block;
  text-align: right;
}

.section-nav { flex: 1; padding: 8px 0; }

.section-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
  user-select: none;
}

.section-nav-item:hover { background: var(--ids-gray-50); }

.section-nav-item.active {
  background: #EBF4FA;
  border-left-color: var(--ids-accent);
}

.section-nav-item .section-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--ids-gray-500);
  min-width: 22px;
  text-align: right;
}

.section-nav-item .section-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--ids-gray-700);
  line-height: 1.3;
}

.section-nav-item.active .section-title { color: var(--ids-blue); font-weight: 600; }

.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.not_started { background: var(--ids-gray-200); }
.status-dot.in_progress { background: var(--ids-yellow); }
.status-dot.complete    { background: var(--ids-green); }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 40px 60px;
  max-width: 1100px;
}

.section-header {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ids-gray-100);
}

.section-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--ids-blue);
  margin-bottom: 6px;
}

.section-header p {
  font-size: 14px;
  color: var(--ids-gray-500);
  line-height: 1.5;
}

.instructions-box {
  background: #EBF4FA;
  border-left: 4px solid var(--ids-accent);
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--ids-gray-700);
  line-height: 1.5;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--ids-gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ids-gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ids-blue);
}

.card-body { padding: 20px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 600px;
}

.portal-table th {
  background: var(--ids-blue);
  color: #fff;
  padding: 10px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--ids-blue-mid);
}

.portal-table td {
  padding: 7px 8px;
  border: 1px solid var(--ids-gray-200);
  vertical-align: middle;
}

.portal-table tr:nth-child(even) td { background: var(--ids-gray-50); }
.portal-table tr:hover td { background: #EBF4FA; }

.portal-table td input,
.portal-table td select {
  width: 100%;
  padding: 5px 7px;
  font-size: 12px;
  border: 1px solid var(--ids-gray-200);
  border-radius: 4px;
  background: #fff;
}

.portal-table td input:focus,
.portal-table td select:focus {
  border-color: var(--ids-accent);
  outline: none;
}

.portal-table .row-delete {
  background: none; border: none; cursor: pointer;
  color: var(--ids-gray-500); font-size: 16px; padding: 2px 6px;
}

.portal-table .row-delete:hover { color: var(--ids-red); }

.table-add-row {
  margin-top: 8px;
}

/* ── Repeating Groups ─────────────────────────────────────────────────────── */
.rg-entry {
  border: 1px solid var(--ids-gray-200);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.rg-entry-header {
  background: var(--ids-gray-100);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.rg-entry-header span {
  font-weight: 600;
  font-size: 14px;
  color: var(--ids-gray-700);
}

.rg-entry-body { padding: 16px; display: none; }
.rg-entry-body.open { display: block; }

/* ── Parts Pricing ────────────────────────────────────────────────────────── */
.parts-group { margin-bottom: 20px; }

.parts-group-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.parts-pricing-table th:first-child,
.parts-pricing-table td:first-child { width: 130px; }

/* ── Section Actions ──────────────────────────────────────────────────────── */
.section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid var(--ids-gray-100);
  margin-top: 24px;
  flex-wrap: wrap;
}

.section-actions .status-badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 99px;
}

.badge-not_started { background: var(--ids-gray-100); color: var(--ids-gray-500); }
.badge-in_progress { background: #FFF3CD; color: #856404; }
.badge-complete    { background: #D4EDDA; color: #155724; }

/* ── Toast Notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  animation: slideIn .25s ease;
  min-width: 260px;
  max-width: 360px;
}

.toast.success { background: var(--ids-green); color: #fff; }
.toast.error   { background: var(--ids-red);   color: #fff; }
.toast.info    { background: var(--ids-blue);  color: #fff; }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ── Admin Dashboard ──────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; flex-direction: column; }

.admin-content { margin-top: var(--header-height); padding: 32px 40px; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--ids-gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--ids-blue);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--ids-gray-500);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Dealer Table ─────────────────────────────────────────────────────────── */
.dealer-list-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dealer-list-table th {
  background: var(--ids-blue);
  color: #fff;
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
}
.dealer-list-table td { padding: 11px 14px; border-bottom: 1px solid var(--ids-gray-100); }
.dealer-list-table tr:hover td { background: var(--ids-gray-50); }

.completion-bar {
  height: 6px;
  background: var(--ids-gray-100);
  border-radius: 99px;
  overflow: hidden;
  width: 100px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.completion-fill {
  height: 100%;
  background: var(--ids-green);
  border-radius: 99px;
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--ids-gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 17px; font-weight: 700; color: var(--ids-blue); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--ids-gray-500); line-height: 1; }
.modal-close:hover { color: var(--ids-gray-900); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 12px 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--ids-gray-500); }
.text-small  { font-size: 12px; }
.text-center { text-align: center; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 10px; }
.flex-1 { flex: 1; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-danger  { background: #F8D7DA; color: #721C24; border: 1px solid #F5C6CB; }
.alert-success { background: #D4EDDA; color: #155724; border: 1px solid #C3E6CB; }
.alert-info    { background: #D1ECF1; color: #0C5460; border: 1px solid #BEE5EB; }
.alert-warning { background: #FFF3CD; color: #856404; border: 1px solid #FFEEBA; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--ids-gray-500);
  font-size: 15px;
  gap: 12px;
}

.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--ids-gray-200);
  border-top-color: var(--ids-blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-rv     { background: #D0E8FF; color: #0057A8; }
.badge-marine { background: #D0F5E8; color: #006644; }
.badge-both   { background: #EDE0FF; color: #5B00A8; }
.badge-active  { background: #D4EDDA; color: #155724; }
.badge-inactive { background: var(--ids-gray-100); color: var(--ids-gray-500); }

/* ── File upload ──────────────────────────────────────────────────────────── */
.file-upload-zone {
  border: 2px dashed var(--ids-gray-200);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.file-upload-zone:hover, .file-upload-zone.drag-over {
  border-color: var(--ids-accent);
  background: #F0F9FF;
}

.file-upload-zone input[type=file] { display: none; }
.file-upload-zone p { font-size: 13px; color: var(--ids-gray-500); margin-top: 6px; }

.uploaded-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #D4EDDA;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 8px;
  color: #155724;
}

/* ── Password change banner ───────────────────────────────────────────────── */
.pw-change-banner {
  background: #FFF3CD;
  border-bottom: 2px solid var(--ids-yellow);
  padding: 10px 24px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: fixed;
  top: var(--header-height);
  left: 0; right: 0;
  z-index: 90;
}

.pw-change-banner + .portal-body { margin-top: 44px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; top: 0; }
  .portal-body { flex-direction: column; }
  .main-content { margin-left: 0; padding: 20px 16px 40px; }
  .form-row { grid-template-columns: 1fr; }
  .admin-content { padding: 20px 16px; }
  .login-card { padding: 32px 24px; }
  .main-content { max-width: 100%; }
}
