/* =============================================================================
   Orange County Roadway Prioritization Tool  —  Stylesheet
   Brand: OC Navy #003C78 · Orange/Gold #F0A050  (matches Modular Roundabout app)
   ============================================================================= */

/* ----------------------------------------------------------------------------
   Custom Properties
   ---------------------------------------------------------------------------- */
:root {
  --primary:      #003C78;   /* OC deep navy blue */
  --primary-dark: #002a58;
  --primary-mid:  #3D6490;
  --blue:         #5078A0;
  --blue-light:   #A0B8CC;
  --blue-mid:     #3D6490;
  --accent:       #F0A050;   /* OC orange / gold */
  --accent-light: #F5C080;
  --accent-bg:    #FEF3E6;
  --green:        #3F9C35;
  --cyan:         #3DB7E4;
  --gold:         #F0A050;
  --white:        #FFFFFF;
  --off-white:    #F0F3F6;
  --bg-soft:      #E6ECF2;
  --light-gray:   #C4CDD4;
  --border:       #C4CDD4;
  --medium-gray:  #7A8C96;
  --gray-dark:    #3A4A56;
  --dark:         #1B242A;
  --text:         #3A4A56;
  --shadow-sm:    0 2px 8px rgba(0,60,120,.10);
  --shadow-md:    0 4px 12px rgba(0,60,120,.15);
  --shadow-lg:    0 4px 20px rgba(0,60,120,.22);
  --radius:       8px;
  --radius-sm:    4px;
  --header-h:     80px;
  --font:         "Interstate", "Segoe UI", Arial, sans-serif;
  --transition:   0.18s ease;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--off-white);
  color: var(--text);
  line-height: 1.55;
}

a { color: var(--blue); }
a:hover { color: var(--primary); }

/* ----------------------------------------------------------------------------
   Header
   ---------------------------------------------------------------------------- */
.oc-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

/* Accent stripe below header — signature Modular Roundabout style */
.oc-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 55%, var(--blue) 100%);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.header-seal {
  height: 52px;
  width: 52px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.3));
}

.header-text { min-width: 0; }

.header-county {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--medium-gray);
}

.header-title {
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-mid); }

.btn-secondary { background: transparent; color: var(--primary); border: 1.5px solid var(--blue-light); }
.btn-secondary:hover { background: var(--bg-soft); border-color: var(--blue); color: var(--blue); }

.btn-outline   { background: transparent; color: var(--primary); border: 2px solid var(--blue-light); }
.btn-outline:hover { background: var(--bg-soft); border-color: var(--blue); color: var(--blue); }

.btn-ghost     { background: transparent; color: var(--gray-dark); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-soft); }

.btn-danger    { background: #DC3545; color: #fff; }
.btn-danger:hover { background: #BB2D3B; }

.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }

/* Storage / auto-save badge in header */
.storage-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 50px;
  font-size: .78rem;
  font-weight: 600;
  border: 1.5px solid;
  background: none;
  white-space: nowrap;
  transition: all var(--transition);
}
.storage-badge.connected {
  color: var(--green);
  border-color: var(--green);
  cursor: pointer;
}
.storage-badge.connected:hover {
  background: rgba(63,156,53,.08);
}
.storage-badge.disconnected {
  color: var(--accent);
  border-color: var(--accent);
  cursor: pointer;
}
.storage-badge.disconnected:hover {
  background: var(--accent-bg);
}

/* icon-only button used in cards */
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--medium-gray);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  font-size: 1rem;
}
.btn-icon:hover { background: var(--bg-soft); color: var(--primary); }

/* ----------------------------------------------------------------------------
   Page Content
   ---------------------------------------------------------------------------- */
.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ----------------------------------------------------------------------------
   Filters / Tab bar
   ---------------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  padding: 14px 16px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.filter-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--medium-gray);
  align-self: center;
  margin-right: 4px;
}

.filter-btn {
  padding: 5px 14px;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover          { border-color: var(--blue); color: var(--primary); }
.filter-btn.active         { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ----------------------------------------------------------------------------
   Stats Bar
   ---------------------------------------------------------------------------- */
.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat-chip {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 5px 14px;
  font-size: .82rem;
  color: var(--medium-gray);
  box-shadow: var(--shadow-sm);
}
.stat-chip strong { color: var(--primary); }

/* ----------------------------------------------------------------------------
   Project Cards
   ---------------------------------------------------------------------------- */
.project-list { display: flex; flex-direction: column; gap: 10px; }

.project-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-left-color var(--transition), transform var(--transition);
}
.project-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Border colour by program type */
.project-card[data-type="widening"]            { border-left-color: var(--primary); }
.project-card[data-type="safety-corridor"]     { border-left-color: #C0392B; }
.project-card[data-type="safety-signalized"]   { border-left-color: #E74C3C; }
.project-card[data-type="safety-unsignalized"] { border-left-color: var(--accent); }
.project-card[data-type="operations"]          { border-left-color: var(--blue); }

.card-rank {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  min-width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.card-body { flex: 1; min-width: 0; }

.card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.type-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 50px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #fff;
}
.badge-widening            { background: var(--primary); }
.badge-safety-corridor     { background: #C0392B; }
.badge-safety-signalized   { background: #E74C3C; }
.badge-safety-unsignalized { background: #D68910; }
.badge-operations          { background: var(--blue); }

.card-segment {
  font-size: .82rem;
  color: var(--medium-gray);
}

.card-score {
  text-align: center;
  flex-shrink: 0;
  min-width: 72px;
}
.score-value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1;
}
.score-label { font-size: .72rem; color: var(--medium-gray); }

/* Score colour gradient */
.score-high   { color: var(--primary); }
.score-mid    { color: var(--accent); }
.score-low    { color: #C0392B; }

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   Empty state
   ---------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--medium-gray);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }
.empty-state p  { font-size: .9rem; }

/* ----------------------------------------------------------------------------
   Modal
   ---------------------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  padding: 20px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; align-items: flex-start; justify-content: center; }

.modal-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 860px;
  margin: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--primary);
  color: #fff;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .15s;
}
.modal-close:hover { background: rgba(255,255,255,.2); color: #fff; }

.modal-body { padding: 24px; overflow-y: auto; max-height: calc(100vh - 200px); }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

/* ----------------------------------------------------------------------------
   Form sections
   ---------------------------------------------------------------------------- */
.form-section {
  margin-bottom: 24px;
  padding: 18px 20px;
  background: var(--off-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title h3 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.weight-chip {
  background: var(--bg-soft);
  color: var(--primary-dark);
  border: 1px solid var(--blue-light);
  border-radius: 50px;
  padding: 2px 10px;
  font-size: .75rem;
  font-weight: 700;
}

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

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-group.half { grid-column: span 2; }

label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
}

label .required { color: #C0392B; margin-left: 2px; }

input[type="text"],
input[type="number"],
select,
textarea {
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text);
  background: var(--white);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,60,120,.12);
}

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.hint {
  font-size: .75rem;
  color: var(--medium-gray);
  margin-top: 2px;
}
.hint a { color: var(--blue); font-weight: 600; }

.radio-group, .checkbox-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.radio-group label, .checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  cursor: pointer;
}

/* Info / help boxes */
.info-box {
  background: var(--bg-soft);
  border: 1px solid var(--blue-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .82rem;
  color: var(--primary-dark);
  margin-top: 8px;
}

.calc-box {
  background: var(--accent-bg);
  border: 1px solid #F5C080;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .82rem;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.calc-box .calc-result {
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
}

/* LOS badge */
.los-badge {
  display: inline-block;
  width: 36px;
  height: 36px;
  line-height: 36px;
  text-align: center;
  border-radius: 50%;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  flex-shrink: 0;
}
.los-A { background: #27AE60; }
.los-B { background: #82C341; }
.los-C { background: #F4D03F; color: #333; }
.los-D { background: #F39C12; }
.los-E { background: #E67E22; }
.los-F { background: #C0392B; }

/* Live score preview in modal */
.score-preview {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.score-preview .preview-label { font-size: .85rem; opacity: .85; }
.score-preview .preview-value { font-size: 2.2rem; font-weight: 800; }
.score-preview .preview-max   { font-size: .85rem; opacity: .6; }

/* Relative-scoring note */
.relative-note {
  background: #FFF8E1;
  border: 1px solid #FFD54F;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: .78rem;
  color: #555;
  margin-top: 8px;
}

/* AADT Map panel */
.map-panel {
  display: none;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 10px;
}
.map-panel.open { display: block; }
.map-panel iframe { display: block; width: 100%; height: 420px; border: none; }
.map-panel-header {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--blue-light);
  padding: 8px 14px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--primary-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Score breakdown table */
.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  margin-top: 12px;
}
.breakdown-table th {
  background: var(--primary);
  color: #fff;
  text-align: left;
  padding: 8px 12px;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.breakdown-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--bg-soft);
}
.breakdown-table tr:last-child td { border-bottom: none; }
.breakdown-table tr:nth-child(even) td { background: var(--off-white); }
.breakdown-table .weighted-col {
  font-weight: 700;
  color: var(--primary-dark);
  text-align: right;
}

/* Programme type selection (first step of modal) */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.type-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}
.type-card:hover { border-color: var(--blue); background: var(--bg-soft); }
.type-card.selected { border-color: var(--primary); background: var(--bg-soft); box-shadow: 0 0 0 3px rgba(0,60,120,.15); }
.type-card .type-icon { font-size: 1.7rem; margin-bottom: 6px; }
.type-card .type-name { font-size: .82rem; font-weight: 700; color: var(--text); }

/* ----------------------------------------------------------------------------
   Confirm/Alert dialogs
   ---------------------------------------------------------------------------- */
.dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dialog-overlay.open { display: flex; }
.dialog-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.dialog-box h3 { margin-bottom: 10px; }
.dialog-box p  { color: var(--medium-gray); font-size: .9rem; margin-bottom: 20px; }
.dialog-actions { display: flex; gap: 10px; justify-content: center; }

/* ----------------------------------------------------------------------------
   LOS Auto-Calculator Panel
   ---------------------------------------------------------------------------- */
.los-calc-panel {
  background: var(--bg-soft);
  border: 1px solid var(--blue-light);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 14px;
}

.los-calc-header {
  font-size: .82rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 14px;
}

/* Volume input method pills */
.method-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.method-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--white);
  color: var(--text);
  transition: all var(--transition);
  user-select: none;
}

.method-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.method-pill:hover { border-color: var(--blue); color: var(--primary); }
.method-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ----------------------------------------------------------------------------
   PRINT STYLES
   ---------------------------------------------------------------------------- */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  .oc-header     { position: relative !important; box-shadow: none !important; }
  .header-actions, .card-actions, .filter-bar, .stats-bar,
  .modal-overlay, .dialog-overlay { display: none !important; }

  body { background: #fff; }

  .page-content { padding: 0; max-width: 100%; }

  .project-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ccc !important;
    margin-bottom: 8px;
  }

  /* --- Individual Project Report --- */
  .print-report {
    font-family: 'Arial', sans-serif;
    color: #000;
    padding: 20px;
  }
  .print-header {
    display: flex !important;
    align-items: center;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 3px solid #003C78;
    margin-bottom: 20px;
  }
  .print-header img { height: 60px; }
  .print-header .ph-county { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: #555; }
  .print-header .ph-title  { font-size: 1.3rem; font-weight: 800; color: #003C78; }
  .print-score-box {
    display: inline-block !important;
    background: #003C78 !important;
    color: #fff !important;
    padding: 12px 24px;
    border-radius: 8px;
    text-align: center;
    float: right;
    margin-left: 20px;
  }
  .print-score-box .big-score { font-size: 2.4rem; font-weight: 900; line-height: 1; }
  .print-score-box .score-out { font-size: .85rem; opacity: .7; }
  .print-footer {
    border-top: 1px solid #ccc;
    padding-top: 10px;
    font-size: .75rem;
    color: #666;
    margin-top: 24px;
    display: flex !important;
    justify-content: space-between;
  }
}

/* ----------------------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .oc-header       { height: auto; min-height: 60px; padding: 10px 14px; flex-wrap: wrap; }
  .header-actions  { gap: 6px; flex-wrap: wrap; }
  .btn-secondary span { display: none; }
  .project-card    { flex-wrap: wrap; }
  .card-rank       { min-width: auto; }
  .type-grid       { grid-template-columns: repeat(2, 1fr); }
  .form-grid       { grid-template-columns: 1fr; }
}
