/* ============================================
   BLACK TIE TABLE — CLIENT PORTAL STYLES
   ============================================ */

:root {
  --gold: #B8A06A;
  --gold-hover: #a08a58;
  --dark: #1A1714;
  --bg: #F7F4EF;
  --white: #ffffff;
  --border-gold: rgba(184, 160, 106, 0.3);
  --text-muted: #6B6560;
  --success: #4A7C59;
  --error: #C0392B;
  --font-heading: 'Cormorant Garamond', serif;
  --font-body: 'DM Sans', sans-serif;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow: 0 2px 16px rgba(26, 23, 20, 0.08);
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.2;
}

/* ============================================
   LOGO
   ============================================ */
.logo-text {
  display: block;
  font-family: var(--font-heading);
  font-variant: small-caps;
  font-size: 1.75rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  font-weight: 600;
  line-height: 1;
}

.logo-subtitle {
  display: block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.75rem;
  background: var(--gold);
  color: var(--dark);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--gold-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-full { width: 100%; }

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--dark);
  border: 1px solid rgba(26, 23, 20, 0.2);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
  white-space: nowrap;
}

.btn-outline:hover {
  border-color: var(--gold);
  background: rgba(184, 160, 106, 0.06);
}

/* ============================================
   LOGIN
   ============================================ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  background: var(--white);
  border: 0.5px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 2.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-group input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(26, 23, 20, 0.15);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input[type="text"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 160, 106, 0.15);
}

/* PIN inputs */
.pin-inputs {
  display: flex;
  gap: 0.75rem;
}

.pin-digit {
  flex: 1;
  padding: 0 !important;
  text-align: center;
  font-size: 1.5rem !important;
  font-weight: 500;
  aspect-ratio: 1;
  max-width: 72px;
  min-height: 56px;
  caret-color: var(--gold);
}

.login-error {
  padding: 0.75rem 1rem;
  background: rgba(192, 57, 43, 0.07);
  border: 1px solid rgba(192, 57, 43, 0.2);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ============================================
   PORTAL HEADER
   ============================================ */
.portal-body {
  padding-bottom: 4rem;
}

.portal-header {
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(184, 160, 106, 0.15);
}

.portal-header .logo-text { font-size: 1.2rem; }

.header-logo { text-decoration: none; }

.header-project-name {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--white);
  text-align: center;
  flex: 1;
  padding: 0 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-signout {
  background: transparent;
  border: 1px solid rgba(184, 160, 106, 0.35);
  color: var(--gold);
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  cursor: pointer;
  min-height: 34px;
  letter-spacing: 0.05em;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-signout:hover { background: rgba(184, 160, 106, 0.1); }

/* ============================================
   WELCOME STRIP
   ============================================ */
.welcome-strip {
  background: var(--dark);
  padding: 1.5rem 2rem 2.25rem;
  border-bottom: 1px solid rgba(184, 160, 106, 0.12);
}

.welcome-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.welcome-greeting {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--white);
  font-weight: 400;
}

.project-type-badge {
  background: rgba(184, 160, 106, 0.12);
  border: 1px solid rgba(184, 160, 106, 0.35);
  color: var(--gold);
  padding: 0.3rem 0.875rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ============================================
   PORTAL MAIN
   ============================================ */
.portal-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.portal-section {
  background: var(--white);
  border: 0.5px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--dark);
  margin-bottom: 1.25rem;
  font-weight: 500;
}

.section-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: -0.875rem;
  margin-bottom: 1.25rem;
}

.section-text {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.65;
  margin-bottom: 1.25rem;
}

/* ============================================
   STATUS TRACKER
   ============================================ */
.delayed-banner {
  background: rgba(184, 160, 106, 0.09);
  border: 1px solid rgba(184, 160, 106, 0.35);
  border-radius: var(--radius);
  padding: 0.875rem 1.125rem 0.875rem 1rem;
  font-size: 0.875rem;
  color: var(--dark);
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.delayed-banner::before {
  content: '⚠';
  color: var(--gold);
  font-size: 1rem;
  flex-shrink: 0;
}

.status-tracker {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.status-tracker::-webkit-scrollbar { display: none; }

.status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 68px;
  position: relative;
  text-align: center;
}

/* Connector line */
.status-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 13px;
  left: calc(50% + 14px);
  right: calc(-50% + 14px);
  height: 2px;
  background: #E5E0D8;
  z-index: 0;
}

.status-step.completed:not(:last-child)::after { background: var(--success); }
.status-step.current:not(:last-child)::after,
.status-step.all-complete:not(:last-child)::after { background: var(--gold); }

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #D8D2C8;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  transition: all 0.25s;
}

.status-step.completed .step-dot {
  background: var(--success);
  border-color: var(--success);
  color: white;
  font-size: 0.8rem;
}

.status-step.current .step-dot {
  border-color: var(--gold);
  border-width: 2.5px;
  box-shadow: 0 0 0 3px rgba(184, 160, 106, 0.18);
}

.status-step.current .step-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
}

.status-step.all-complete .step-dot {
  background: var(--gold);
  border-color: var(--gold);
  color: white;
  font-size: 0.8rem;
}

.step-label {
  margin-top: 0.5rem;
  font-size: 0.6rem;
  font-weight: 500;
  color: #9B9590;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.3;
  max-width: 64px;
}

.status-step.completed .step-label { color: var(--success); }
.status-step.current .step-label { color: var(--gold); font-weight: 600; }
.status-step.all-complete .step-label { color: var(--gold); }

/* ============================================
   VIDEO SECTION
   ============================================ */
.video-container {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  margin-bottom: 0;
}

.video-container iframe,
.video-container video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border: none;
}

.video-approval {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-gold);
}

.approval-prompt {
  font-size: 0.9375rem;
  color: var(--dark);
  margin-bottom: 1rem;
  font-weight: 400;
}

.approval-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.initials-input {
  padding: 0.625rem 0.875rem;
  border: 1px solid rgba(26, 23, 20, 0.15);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9rem;
  width: 160px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  min-height: 44px;
  background: var(--white);
}

.initials-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 160, 106, 0.15);
}

.approved-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: rgba(74, 124, 89, 0.09);
  border: 1px solid rgba(74, 124, 89, 0.25);
  border-radius: var(--radius);
  color: var(--success);
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 1rem;
}

/* ============================================
   PROGRESS PHOTOS
   ============================================ */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}

.photo-item {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: #EDE9E2;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s;
}

.photo-item:hover img { transform: scale(1.04); }

.photo-date {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.5rem 0.375rem;
  font-size: 0.625rem;
  color: rgba(255, 255, 255, 0.9);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
  letter-spacing: 0.03em;
}

.photos-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ============================================
   DOCUMENTS
   ============================================ */
.documents-tree {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.doc-folder {
  border: 1px solid rgba(26, 23, 20, 0.08);
  border-radius: var(--radius);
  overflow: hidden;
}

.doc-folder-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--dark);
  transition: background 0.15s;
}

.doc-folder-header:hover { background: rgba(184, 160, 106, 0.08); }

.folder-chevron {
  margin-left: auto;
  transition: transform 0.2s;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1;
}

.doc-folder.open .folder-chevron { transform: rotate(90deg); }

.doc-folder-contents {
  display: none;
  padding: 0.375rem;
  border-top: 1px solid rgba(26, 23, 20, 0.06);
  background: var(--white);
  flex-direction: column;
  gap: 0.125rem;
}

.doc-folder.open .doc-folder-contents { display: flex; }

.doc-folder-contents .doc-folder {
  margin: 0.125rem 0;
}

.doc-file {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--dark);
  font-size: 0.875rem;
  transition: background 0.15s;
  min-height: 44px;
}

.doc-file:hover { background: rgba(184, 160, 106, 0.07); }

.file-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.file-info { flex: 1; min-width: 0; }

.file-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.docs-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ============================================
   CHANGE ORDERS
   ============================================ */
.change-orders-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.change-order-card {
  border: 1px solid rgba(26, 23, 20, 0.09);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.change-order-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.375rem;
}

.change-order-title {
  font-weight: 500;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.change-order-price {
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.price-positive { color: var(--gold); }
.price-negative { color: var(--success); }

.change-order-description {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.875rem;
  line-height: 1.55;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.badge-pending {
  background: rgba(184, 160, 106, 0.1);
  border: 1px solid rgba(184, 160, 106, 0.3);
  color: #8a7040;
}

.badge-approved {
  background: rgba(74, 124, 89, 0.09);
  border: 1px solid rgba(74, 124, 89, 0.25);
  color: var(--success);
}

.badge-rejected {
  background: rgba(26, 23, 20, 0.05);
  border: 1px solid rgba(26, 23, 20, 0.1);
  color: var(--text-muted);
}

.change-order-approval {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(26, 23, 20, 0.07);
}

.approval-note {
  font-size: 0.875rem;
  color: var(--dark);
  margin-bottom: 0.75rem;
}

.co-approval-form {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  flex-wrap: wrap;
}

.co-contact-link {
  font-size: 0.8rem;
  color: var(--gold);
  text-decoration: none;
}

.co-contact-link:hover { text-decoration: underline; }

/* ============================================
   BALANCE
   ============================================ */
.balance-card {
  display: flex;
  flex-direction: column;
}

.balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 0;
  border-bottom: 1px solid rgba(26, 23, 20, 0.07);
  font-size: 0.9375rem;
}

.balance-label { color: var(--text-muted); }
.balance-value { font-weight: 500; }

.balance-remaining-row {
  padding: 1.25rem 0 0.5rem;
  border-bottom: none;
  border-top: 2px solid rgba(26, 23, 20, 0.09);
  margin-top: 0.25rem;
  align-items: center;
}

.balance-remaining-label {
  font-size: 0.875rem;
  font-weight: 500;
}

.balance-remaining-value {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  color: var(--gold);
  font-weight: 600;
  line-height: 1;
}

.balance-disclaimer {
  font-style: italic;
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 1rem;
  line-height: 1.6;
}

/* ============================================
   CONTACT
   ============================================ */
.contact-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--dark);
  padding: 0.5rem 0;
  border-radius: var(--radius);
  transition: color 0.15s;
  min-height: 44px;
}

.contact-item:hover { color: var(--gold); }

.contact-icon {
  width: 36px;
  height: 36px;
  background: rgba(184, 160, 106, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--gold);
  flex-shrink: 0;
}

/* ============================================
   REVIEW + REFERRAL
   ============================================ */
.review-referral-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
}

.review-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ============================================
   LIGHTBOX
   ============================================ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

.lightbox[hidden] { display: none; }

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 2.25rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
  z-index: 1001;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover { color: white; }

.lightbox-img {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius);
}

/* ============================================
   APPROVED INLINE BADGE
   ============================================ */
.approved-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--success);
  margin-top: 0.625rem;
  font-weight: 500;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .portal-header {
    padding: 0.75rem 1rem;
  }

  .portal-header .logo-text { font-size: 1rem; }

  .header-project-name {
    font-size: 0.9rem;
    padding: 0 0.5rem;
  }

  .welcome-strip {
    padding: 1.25rem 1rem 1.75rem;
  }

  .welcome-greeting { font-size: 1.625rem; }

  .portal-main {
    padding: 1.25rem 1rem;
    gap: 1.25rem;
  }

  .portal-section { padding: 1.25rem; }

  .status-step { min-width: 52px; }
  .step-label { font-size: 0.55rem; max-width: 50px; }

  .photos-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }

  .review-referral-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .balance-remaining-value { font-size: 1.875rem; }

  .approval-form,
  .co-approval-form {
    flex-direction: column;
    align-items: stretch;
  }

  .initials-input { width: 100%; }
}

@media (max-width: 420px) {
  .login-card { padding: 2rem 1.25rem; }
  .pin-inputs { gap: 0.5rem; }
}
