/* ── PORSCHE-INSPIRED PALETTE ─────────────────────────────────────────────── */
:root {
  --bg:           #f0f0ee;       /* warm light gray — Porsche studio floor */
  --surface:      #ffffff;
  --surface-2:    #f7f7f5;
  --border:       #e0dedd;
  --border-light: #cccbc8;

  --text:         #1a1917;       /* near-black */
  --text-muted:   #6b6966;
  --text-dim:     #aaa9a6;

  --nav-bg:       #ffffff;
  --nav-border:   #e0dedd;
  --nav-h:        56px;

  --accent-green: #2d6a4f;       /* CREATE RECORD green */
  --accent-green-hover: #1b4332;
  --accent-dark:  #1a1917;

  --success:  #2d6a4f;
  --danger:   #c0392b;
  --warning:  #b7791f;
  --info:     #1d4e89;

  --radius:    10px;
  --radius-sm: 6px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── TOP NAV ──────────────────────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 0;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.topnav-brand {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 28px;
  white-space: nowrap;
  flex-shrink: 0;
}
.topnav-brand i { font-size: 17px; }

.topnav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav-links::-webkit-scrollbar { display: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  border-radius: var(--radius-sm);
  transition: all .15s;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.nav-link:hover  { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); border-bottom-color: var(--text); background: transparent; }

/* CREATE RECORD — stands out in green */
.nav-link-create {
  background: var(--accent-green);
  color: #fff !important;
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  border-bottom: none !important;
  margin-right: 6px;
  transition: background .15s;
}
.nav-link-create:hover { background: var(--accent-green-hover) !important; color: #fff !important; }

.topnav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.topnav-user {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.topnav-logout {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: all .15s;
}
.topnav-logout:hover { color: var(--danger); background: #fef2f2; }

/* Mobile hamburger */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 16px;
}

/* ── PAGE LAYOUT ──────────────────────────────────────────────────────────── */
.page-wrapper {
  min-height: calc(100vh - var(--nav-h));
  padding: 20px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── CARDS ────────────────────────────────────────────────────────────────── */
.card-dark {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.card-header-dark {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
}
.card-body-dark { padding: 16px; }

/* ── FORMS ────────────────────────────────────────────────────────────────── */
.form-control-dark, .form-select-dark {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  font-family: 'Inter', sans-serif;
}
.form-control-dark:focus, .form-select-dark:focus {
  outline: none;
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 3px rgba(26,25,23,0.08);
}
.form-control-dark::placeholder { color: var(--text-dim); }
label.form-label-dark {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}
textarea.form-control-dark { resize: vertical; }

/* ── BUTTONS ──────────────────────────────────────────────────────────────── */
.btn-dark-primary {
  background: var(--accent-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: pointer;
  transition: opacity .15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}
.btn-dark-primary:hover { opacity: .82; color: #fff; }

.btn-dark-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn-dark-secondary:hover { border-color: var(--border-light); background: var(--surface-2); color: var(--text); }

.btn-green {
  background: var(--accent-green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: pointer;
  transition: background .15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}
.btn-green:hover { background: var(--accent-green-hover); color: #fff; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color .15s, background .15s;
  display: inline-flex;
  align-items: center;
}
.btn-icon:hover { color: var(--text); background: var(--surface-2); }
.btn-icon.danger:hover { color: var(--danger); background: #fef2f2; }

/* ── BADGES ───────────────────────────────────────────────────────────────── */
.badge-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-active    { background: #d1fae5; color: #065f46; }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-completed { background: #dbeafe; color: #1e40af; }
.badge-inactive  { background: #f3f4f6; color: #6b7280; }
.badge-dropped   { background: #fee2e2; color: #991b1b; }
.badge-paid      { background: #d1fae5; color: #065f46; }
.badge-upcoming  { background: #fef3c7; color: #92400e; }
.badge-failed    { background: #fee2e2; color: #991b1b; }
.badge-refunded  { background: #e0e7ff; color: #3730a3; }
.badge-present   { background: #d1fae5; color: #065f46; }
.badge-absent    { background: #fee2e2; color: #991b1b; }
.badge-dismissed { background: #f3f4f6; color: #6b7280; }
.badge-pass      { background: #d1fae5; color: #065f46; }
.badge-fail      { background: #fee2e2; color: #991b1b; }
.badge-postponed { background: #fef3c7; color: #92400e; }
.badge-scheduled { background: #dbeafe; color: #1e40af; }
.badge-signed    { background: #d1fae5; color: #065f46; }

/* ── TABLE ────────────────────────────────────────────────────────────────── */
.table-dark-custom { width: 100%; border-collapse: collapse; }
.table-dark-custom th {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-muted);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  text-align: left; background: var(--surface-2);
}
.table-dark-custom td {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.table-dark-custom tr:last-child td { border-bottom: none; }
.table-dark-custom tr:hover td { background: var(--surface-2); }

/* ── SIGNATURE ────────────────────────────────────────────────────────────── */
.sig-field {
  font-family: 'Dancing Script', cursive;
  font-size: 28px;
  color: var(--text);
  border: none;
  border-bottom: 2px solid var(--border);
  background: transparent;
  width: 100%;
  padding: 4px 0;
  cursor: text;
  transition: border-color .15s;
}
.sig-field:focus { outline: none; border-bottom-color: var(--accent-dark); }
.sig-field.signed { pointer-events: none; color: #1d4e89; border-bottom-color: #1d4e89; }

/* ── CONTRACT PREVIEW ─────────────────────────────────────────────────────── */
.contract-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 52px;
  font-family: 'Times New Roman', serif;
  font-size: 12px;
  line-height: 1.75;
  color: #1a1917;
  box-shadow: 0 2px 16px rgba(0,0,0,0.07);
}
.contract-preview .school-header { text-align: center; margin-bottom: 20px; font-family: 'Inter', sans-serif; }
.contract-preview .school-name   { font-size: 18px; font-weight: 800; letter-spacing: -.4px; }
.contract-preview h2             { font-size: 15px; text-align: center; text-decoration: underline; margin-bottom: 6px; font-family: 'Inter', sans-serif; font-weight: 700; }
.contract-preview .section-title { font-weight: 700; font-family: 'Inter', sans-serif; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; margin: 18px 0 5px; }
.contract-preview .field-line    { border-bottom: 1px solid #555; display: inline-block; min-width: 120px; margin: 0 2px; }
.contract-preview .checkbox-row  { display: flex; gap: 48px; margin: 10px 0; font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 700; }
.contract-preview .highlight     { background: #fefce8; border-left: 3px solid #ca8a04; padding: 7px 12px; margin: 6px 0; font-size: 11.5px; }
.contract-preview .sig-section   { margin-top: 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.contract-preview .sig-line      { border-bottom: 1px solid #333; padding-top: 28px; font-family: 'Dancing Script', cursive; font-size: 24px; color: #1d4e89; }
.contract-preview .sig-label     { font-size: 10px; color: #666; font-family: 'Inter', sans-serif; margin-top: 2px; }
.contract-preview .footer-info   { margin-top: 22px; padding-top: 12px; border-top: 1px solid #ddd; font-size: 10px; font-family: 'Inter', sans-serif; color: #666; }

/* ── SCHEDULE GRID ────────────────────────────────────────────────────────── */
.schedule-grid { overflow-x: auto; border-radius: var(--radius); }
.schedule-table { border-collapse: collapse; min-width: 100%; background: var(--surface); }
.schedule-table th, .schedule-table td { border: 1px solid var(--border); padding: 0; min-width: 110px; }
.schedule-table th { background: var(--surface-2); font-size: 11px; font-weight: 700; text-align: center; padding: 10px 6px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.schedule-table .time-cell { background: var(--surface-2); font-size: 11px; color: var(--text-muted); padding: 7px 10px; white-space: nowrap; min-width: 65px; text-align: right; font-weight: 700; }
.slot-cell { min-height: 42px; padding: 4px; vertical-align: top; cursor: pointer; transition: background .1s; }
.slot-cell:hover { background: #f0f4ed; }
.slot-chip { background: #e8f4e8; border: 1px solid #b7d9b7; border-radius: 4px; padding: 3px 7px; font-size: 10px; display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 2px; color: #1b4332; }

/* ── SEARCH ───────────────────────────────────────────────────────────────── */
.search-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
  width: 100%;
  font-family: 'Inter', sans-serif;
  transition: border-color .15s, box-shadow .15s;
}
.search-bar:focus { outline: none; border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(26,25,23,0.08); }

/* ── DIVIDER ──────────────────────────────────────────────────────────────── */
.section-divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ── TOAST ────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; }
.toast-msg {
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 8px;
  animation: slideIn .2s ease;
  max-width: 300px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.toast-msg.success { border-left: 3px solid #2d6a4f; }
.toast-msg.danger  { border-left: 3px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── AUTH ─────────────────────────────────────────────────────────────────── */
.auth-wrapper { min-height: 100vh; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}

/* ── MISC ─────────────────────────────────────────────────────────────────── */
.text-muted-custom   { color: var(--text-muted); }
.text-success-custom { color: var(--success); }
.text-danger-custom  { color: var(--danger); }
.text-warning-custom { color: var(--warning); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-11  { font-size: 11px; }

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topnav { padding: 0 16px; }
  .topnav-links { display: none; }
  .topnav-links.open { display: flex; flex-direction: column; position: fixed; top: var(--nav-h); left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px; z-index: 300; gap: 4px; }
  .nav-hamburger { display: flex; }
  .page-wrapper { padding: 14px 16px; }
  .topnav-user { display: none; }
}

/* ── EQUAL HEIGHT CARDS ── */
.card-row { display: flex; gap: 16px; align-items: stretch; }
.card-row .card-dark { flex: 1; }

/* ── AUTO-SAVE INDICATOR ── */
.autosave-indicator {
  position: fixed;
  bottom: 70px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .3s;
  z-index: 8000;
}
.autosave-indicator.show { opacity: 1; }
.autosave-indicator.saving { background: var(--warning); }
.autosave-indicator.saved  { background: var(--success); }

/* ── HISTORY LOG ── */
.history-entry {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.history-entry:last-child { border-bottom: none; }
.history-action { font-weight: 700; color: var(--text); }
.history-meta   { color: var(--text-muted); margin-top: 1px; }

/* ── CONTRACT SPLIT VIEW ── */
.contract-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1024px) { .contract-split { grid-template-columns: 1fr; } }

/* ── STEP FLOW ── */
.step-bar { display: flex; align-items: center; gap: 0; margin-bottom: 24px; }
.step-item { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.step-item.active { color: var(--text); }
.step-item.done   { color: var(--success); }
.step-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.step-item.active .step-dot { background: var(--text); color: #fff; }
.step-item.done .step-dot   { background: var(--success); color: #fff; }
.step-line { flex: 1; height: 1px; background: var(--border); margin: 0 8px; }

/* ── MOBILE IMPROVEMENTS ─────────────────────────────────────────────────── */
@media (max-width: 576px) {
  /* Tighter page padding on phones */
  .page-wrapper { padding: 10px 12px; }

  /* Stack columns fully */
  .row.g-3 > [class*="col-xl-"] { width: 100% !important; }

  /* Topnav compact */
  .topnav { padding: 0 12px; }
  .topnav-brand { font-size: 13px; margin-right: 0; }

  /* Stat cards 2-up */
  .col-6 { width: 50% !important; }

  /* Cards less padding */
  .card-body-dark { padding: 12px; }
  .card-header-dark { padding: 8px 12px; }

  /* Document cards scroll horizontally */
  .doc-card { min-width: 90px; }

  /* Form inputs full width on mobile */
  .form-control-dark, .form-select-dark { font-size: 16px !important; } /* prevent iOS zoom */

  /* Tables — hide less important cols already handled by d-none classes */

  /* Buttons full width in stacks */
  .btn-dark-primary, .btn-dark-secondary, .btn-green {
    font-size: 12px;
    padding: 8px 12px;
  }

  /* Record header wraps cleanly */
  h1 { font-size: 1.1rem !important; }

  /* Transaction blocks */
  .tx-header { flex-wrap: wrap; gap: 6px; }

  /* Dashboard table horizontal scroll */
  .card-dark > div[style*="overflow-x"] { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 768px) {
  /* Nav links hidden on mobile — hamburger handles it */
  .topnav-links { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Lightbox full screen on mobile */
  .lightbox-inner { width: 95vw !important; max-width: 95vw !important; padding: 16px; }

  /* Contract split view stacks */
  .contract-split { grid-template-columns: 1fr; }

  /* Sticky preview becomes normal */
  .contract-split > div:last-child { position: static !important; }
}

/* Touch targets */
.nav-link, .btn-dark-primary, .btn-dark-secondary, .btn-green, .btn-icon {
  min-height: 36px;
}

/* Smooth scrolling */
html { scroll-behavior: smooth; }

/* Better tap highlight */
a, button { -webkit-tap-highlight-color: rgba(0,0,0,0.05); }
