/* ============================================
   KDB Subs — Subcontractor Portal
   Keystone Design Build
   ============================================ */

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

:root {
  --navy: #1B2A4A;
  --navy-light: #243656;
  --blue: #2E6DAD;
  --blue-hover: #245a91;
  --gold: #D4952B;
  --gold-hover: #b87f24;
  --green: #2D8A4E;
  --gray-50: #F8F9FA;
  --gray-100: #F1F3F5;
  --gray-200: #E9ECEF;
  --gray-300: #DEE2E6;
  --gray-400: #CED4DA;
  --gray-500: #ADB5BD;
  --gray-600: #868E96;
  --gray-700: #495057;
  --gray-800: #343A40;
  --gray-900: #212529;
  --white: #FFFFFF;
  --red: #C0392B;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
  --max-width: 1200px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--gray-800);
  background: var(--white);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--blue-hover); }

img { max-width: 100%; height: auto; display: block; }

/* --- Typography --- */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; color: var(--gray-900); }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

/* --- Layout --- */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* --- Header (matches keystonedb.com) --- */
.site-header {
  background: var(--white);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--gray-200);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
}

.header-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo img { height: 48px; width: auto; }

.header-nav { display: flex; align-items: center; gap: 4px; }

.header-nav a {
  color: var(--gray-800);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.header-nav a:hover { color: var(--gray-900); background: var(--gray-50); }

.header-nav a.active {
  color: var(--gray-900);
  border: 1.5px solid var(--gray-800);
  border-radius: 100px;
  padding: 6px 16px;
}

.header-nav .btn-contact {
  background: var(--gold);
  color: var(--white);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 600;
  margin-left: 8px;
}

.header-nav .btn-contact:hover { background: var(--gold-hover); color: var(--white); }

.header-divider {
  width: 1px;
  height: 32px;
  background: var(--gray-300);
  margin: 0 12px;
}

.header-nav .portal-tag {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blue);
  background: #EBF3FB;
  padding: 4px 10px;
  border-radius: 100px;
  margin-left: 4px;
}

/* --- Hero --- */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  padding: 64px 0 56px;
  color: var(--white);
}

.hero h1 { color: var(--white); font-size: 2.5rem; margin-bottom: 12px; }

.hero p { color: rgba(255,255,255,0.8); font-size: 1.15rem; max-width: 600px; margin-bottom: 32px; }

.hero-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
}
.btn-primary:hover { background: var(--blue-hover); color: var(--white); }

.btn-gold {
  background: var(--gold);
  color: var(--white);
}
.btn-gold:hover { background: var(--gold-hover); color: var(--white); }

.btn-outline {
  background: transparent;
  color: var(--white);
  border: 1.5px solid rgba(255,255,255,0.35);
}
.btn-outline:hover { border-color: rgba(255,255,255,0.7); color: var(--white); }

.btn-outline-dark {
  background: transparent;
  color: var(--blue);
  border: 1.5px solid var(--gray-300);
}
.btn-outline-dark:hover { border-color: var(--blue); background: var(--gray-50); }

.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,0.7);
  padding: 12px 16px;
}
.btn-ghost:hover { color: var(--white); }

.btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }

.btn svg { width: 16px; height: 16px; }

/* --- Project Grid --- */
.section { padding: 56px 0; }
.section-header { margin-bottom: 32px; }
.section-header h2 { margin-bottom: 4px; }
.section-header p { color: var(--gray-600); }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.project-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
}
.project-card:hover { box-shadow: var(--shadow-md); border-color: var(--gray-300); transform: translateY(-2px); }

.project-card-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--gray-100);
}

.project-card-body { padding: 20px; }

.project-card-body h3 { margin-bottom: 4px; }

.project-card-location {
  color: var(--gray-600);
  font-size: 0.875rem;
  margin-bottom: 10px;
}

.project-card-desc {
  color: var(--gray-700);
  font-size: 0.875rem;
  margin-bottom: 16px;
  line-height: 1.5;
}

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-card-link {
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.project-card-link:hover { gap: 8px; }

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-green { background: #E8F5E9; color: #2D8A4E; }
.badge-green::before { background: #2D8A4E; }

.badge-blue { background: #E3F2FD; color: #1565C0; }
.badge-blue::before { background: #1565C0; }

.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-gray::before { background: var(--gray-500); }

/* --- Apply Banner --- */
.apply-banner {
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  padding: 40px 0;
  text-align: center;
}

.apply-banner h3 { color: var(--gray-700); font-weight: 500; margin-bottom: 8px; }

.apply-banner a { font-weight: 600; }

/* --- Project Detail Page --- */
.project-hero {
  position: relative;
  padding: 0;
  color: var(--white);
  overflow: hidden;
  min-height: 280px;
  display: flex;
  align-items: center;
}

.project-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}

.project-hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(27,42,74,0.92) 0%, rgba(27,42,74,0.6) 50%, rgba(27,42,74,0.3) 100%);
}

.project-hero .container {
  position: relative;
  z-index: 1;
  padding-top: 40px;
  padding-bottom: 40px;
  width: 100%;
}

.project-hero h1 {
  color: var(--white);
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.breadcrumb {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 16px;
}

.breadcrumb a { color: rgba(255,255,255,0.7); }
.breadcrumb a:hover { color: var(--white); }

.project-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.project-meta-item {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  gap: 6px;
}

.project-meta-item svg { width: 15px; height: 15px; opacity: 0.7; }

.project-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* --- Document Browser --- */
.doc-section { padding: 40px 0; }

.doc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.doc-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  width: 280px;
  max-width: 100%;
}

.doc-search input {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.875rem;
  width: 100%;
  background: transparent;
}

.doc-search svg { width: 16px; height: 16px; color: var(--gray-500); flex-shrink: 0; }

.doc-category {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
}

.doc-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.doc-category-header:hover { background: var(--gray-50); }

.doc-category-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 0.95rem;
}

.doc-category-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
}

.doc-category-icon svg { width: 18px; height: 18px; }

.doc-category-count {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 100px;
}

.doc-category-chevron {
  color: var(--gray-400);
  transition: transform var(--transition);
}

.doc-category.open .doc-category-chevron { transform: rotate(180deg); }

.doc-category-files { display: none; border-top: 1px solid var(--gray-200); }

.doc-category.open .doc-category-files { display: block; }

.doc-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 12px 66px;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}

.doc-file:last-child { border-bottom: none; }
.doc-file:hover { background: var(--gray-50); }

.doc-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.doc-file-icon { color: var(--red); flex-shrink: 0; }
.doc-file-icon svg { width: 18px; height: 18px; }

.doc-file-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gray-800);
}

a.doc-file-name { cursor: pointer; }
a.doc-file-name:hover { color: var(--blue); }

.doc-file-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.doc-file-size {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-variant-numeric: tabular-nums;
}

.doc-file-download {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  transition: all var(--transition);
}

.doc-file-download:hover { background: var(--gray-100); color: var(--blue); }
.doc-file-download svg { width: 16px; height: 16px; }

.doc-file-view {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  transition: all var(--transition);
  cursor: pointer;
}
.doc-file-view:hover { background: var(--gray-100); color: var(--blue); }
.doc-file-view svg { width: 16px; height: 16px; }

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

.modal-overlay.active { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.modal-header h2 { font-size: 1.3rem; }

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--gray-600);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--gray-200); color: var(--gray-900); }
.modal-close svg { width: 18px; height: 18px; }

.modal-body { padding: 24px; }

/* --- Forms --- */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-label .required { color: var(--red); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-800);
  transition: border-color var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(46,109,173,0.12);
}

.form-textarea { min-height: 100px; resize: vertical; }

.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23868E96' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

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

.form-hint { font-size: 0.8rem; color: var(--gray-500); margin-top: 4px; }

/* File Upload */
.file-upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-md);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--gray-50);
}

.file-upload-zone:hover { border-color: var(--blue); background: #f0f6fc; }
.file-upload-zone.dragover { border-color: var(--blue); background: #e3f0fc; }

.file-upload-zone svg { width: 32px; height: 32px; color: var(--gray-400); margin: 0 auto 8px; }

.file-upload-zone p { font-size: 0.9rem; color: var(--gray-600); }
.file-upload-zone p strong { color: var(--blue); }

.file-upload-zone .hint { font-size: 0.8rem; color: var(--gray-500); margin-top: 4px; }

.file-list { margin-top: 10px; }

.file-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.file-list-item .name { font-weight: 500; }
.file-list-item .size { color: var(--gray-500); font-size: 0.8rem; }

.file-list-item .remove {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 2px;
}
.file-list-item .remove:hover { color: var(--red); }

/* Form Submit */
.form-submit { margin-top: 24px; display: flex; gap: 12px; }

/* Success State */
.form-success {
  text-align: center;
  padding: 40px 20px;
}

.form-success svg { width: 56px; height: 56px; color: var(--green); margin: 0 auto 16px; }
.form-success h3 { margin-bottom: 8px; }
.form-success p { color: var(--gray-600); font-size: 0.95rem; }

/* --- Footer (matches keystonedb.com) --- */
.site-footer {
  background: #111111;
  color: rgba(255,255,255,0.65);
  padding: 64px 0 0;
  font-size: 0.9rem;
}

.footer-top {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 48px;
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 48px;
}

.footer-brand img { height: 44px; width: auto; margin-bottom: 24px; filter: invert(1) brightness(2); }

.footer-newsletter { margin-top: 8px; }

.footer-newsletter h4 {
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.footer-newsletter-form {
  display: flex;
  gap: 0;
  background: #333;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.footer-newsletter-form input {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--white);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
}

.footer-newsletter-form input::placeholder { color: rgba(255,255,255,0.4); }

.footer-newsletter-form button {
  background: var(--gold);
  color: var(--white);
  border: none;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.footer-newsletter-form button:hover { background: var(--gold-hover); }

.footer-col h4 {
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

.footer-col ul { list-style: none; }

.footer-col ul li { margin-bottom: 10px; }

.footer-col ul a {
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  transition: color var(--transition);
}

.footer-col ul a:hover { color: var(--white); }

.footer-cta {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 32px;
}

.footer-cta a {
  display: block;
  background: var(--gold);
  color: var(--white);
  text-align: center;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1rem;
  transition: background var(--transition);
}

.footer-cta a:hover { background: var(--gold-hover); color: var(--white); }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.4);
}

.footer-bottom a { color: rgba(255,255,255,0.4); }
.footer-bottom a:hover { color: var(--white); }

/* --- Multi-Select --- */
.multi-select-container {
  position: relative;
}

.multi-select-trigger {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-800);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  transition: border-color var(--transition);
}

.multi-select-trigger:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(46,109,173,0.12);
  outline: none;
}

.multi-select-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.multi-select-tag {
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
}

.multi-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
}

.multi-select-dropdown.open { display: block; }

.multi-select-option {
  padding: 8px 14px;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.multi-select-option:hover { background: var(--gray-50); }

.multi-select-option input[type="checkbox"] {
  accent-color: var(--blue);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  h1 { font-size: 1.75rem; }
  .hero { padding: 40px 0 36px; }
  .hero h1 { font-size: 2rem; }
  .hero-actions { flex-direction: column; align-items: flex-start; }
  .project-grid { grid-template-columns: 1fr; }
  .header-nav { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .project-actions { flex-direction: column; align-items: flex-start; }
  .doc-file { padding-left: 18px; }
  .doc-file-meta .doc-file-size { display: none; }
  .doc-search { width: 100%; }
  .modal { margin: 20px; }
  .footer-top { grid-template-columns: 1fr; gap: 32px; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .header-divider { display: none; }
  .header-nav .portal-tag { display: none; }
}
