/* =====================================================
   STARLINK VMS — Visitors Module CSS
   (SCR-20: Log, SCR-21: Detail, SCR-22: Pre-register, SCR-23: Edit)
   ===================================================== */

/* =====================================================
   Page Sub-header (visitors page top bar)
   ===================================================== */
.page-subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.page-subheader__left h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-navy);
}

/* Export dropdown */
.export-dropdown {
  position: relative;
  display: inline-block;
}

.export-dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  border: 1px solid var(--color-border-light);
  min-width: 180px;
  overflow: hidden;
  z-index: 50;
  animation: slideDown 150ms ease;
}

/* =====================================================
   Visitor Log Table Wrapper
   ===================================================== */
.visitor-log-wrap {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden; /* keeps rounded corners clipped */
  margin-top: var(--space-4);
}

/* Horizontal scroll scoped ONLY to the table rows — filters & pagination stay fixed */
#log-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#log-table-wrap::-webkit-scrollbar {
  height: 6px;
}
#log-table-wrap::-webkit-scrollbar-track {
  background: var(--color-bg);
}
#log-table-wrap::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 99px;
}
#log-table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* =====================================================
   Visitor Detail Page (SCR-21)
   ===================================================== */
.visitor-detail-layout {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: var(--space-6);
  align-items: start;
}

@media (max-width: 1024px) {
  .visitor-detail-layout { grid-template-columns: 1fr; }
}

/* Visitor Card (top of left col) */
.visitor-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.visitor-card__info { flex: 1; }

.visitor-card__name {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 4px;
}

.visitor-card__company {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
}

.visitor-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

@media (max-width: 640px) {
  .visitor-card {
    padding: var(--space-4);
    flex-direction: column;
    text-align: center;
  }
  .visitor-card__meta { justify-content: center; }
  .visitor-info-table { padding: var(--space-4); }
  .info-grid { grid-template-columns: 1fr; gap: var(--space-2); }
}


.visitor-card__quickstat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  padding: 4px 10px;
  background: var(--color-bg);
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-light);
}

/* On-site duration ticker */
.onsite-ticker {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-success);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Timeline */
.visit-timeline {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
}

.visit-timeline__heading {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-navy);
  margin-bottom: var(--space-5);
}

.timeline-list {
  position: relative;
  padding-left: var(--space-8);
}

.timeline-list::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--color-border-light);
}

.timeline-event {
  position: relative;
  margin-bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-event:last-child { margin-bottom: 0; }

.timeline-event__dot {
  position: absolute;
  left: -28px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-border);
  border: 2px solid white;
  outline: 2px solid var(--color-border);
}

.timeline-event__dot--green {
  background: var(--color-success);
  outline-color: var(--color-success);
}

.timeline-event__dot--grey {
  background: var(--color-placeholder);
  outline-color: var(--color-placeholder);
}

.timeline-event__label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
}

.timeline-event__time {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Visitor Info Table */
.visitor-info-table {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
}

.visitor-info-table__heading {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-navy);
  margin-bottom: var(--space-4);
}

.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-3) var(--space-6);
}

.info-grid__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.info-grid__value {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

/* Right Column — Actions & Compliance */
.detail-actions-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  position: sticky;
  top: calc(var(--app-bar-height) + var(--space-4));
}

.detail-actions-card h3 {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

.detail-actions-card .btn {
  margin-bottom: var(--space-2);
  justify-content: flex-start;
  gap: var(--space-3);
}

.detail-actions-card .btn:last-child { margin-bottom: 0; }

.compliance-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}

.compliance-card__heading {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

.compliance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--font-size-sm);
}

.compliance-row:last-child { border-bottom: none; }

.compliance-row__label { color: var(--color-text-secondary); }
.compliance-row__value { font-weight: 500; color: var(--color-text); }
.compliance-row__value--yes { color: var(--color-success); }
.compliance-row__value--no  { color: var(--color-error); }

.signature-thumbnail {
  margin-top: var(--space-4);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  cursor: pointer;
}

.signature-thumbnail img {
  max-width: 120px;
  max-height: 60px;
  object-fit: contain;
}

.signature-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-align: center;
}

/* =====================================================
   Pre-Register Form (SCR-22) / Edit (SCR-23)
   ===================================================== */
.visitor-form-page {
  max-width: 720px;
  margin: 0 auto;
}

.visitor-form-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-8);
  margin-bottom: 110px; /* room for sticky footer + design footer strip */
}

/* Sticky footer */
.visitor-form-footer {
  position: fixed;
  bottom: 30px; /* clears the fixed design-footer strip */
  left: var(--sidebar-width);
  right: 0;
  background: white;
  border-top: 1px solid var(--color-border-light);
  padding: var(--space-4) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.visitor-form-footer--with-cancel {
  justify-content: space-between;
}

.cancel-visit-link {
  color: var(--color-error);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
}

@media (max-width: 640px) {
  .visitor-form-card { padding: var(--space-5); margin-bottom: 120px; }
  .visitor-form-footer {
    padding: var(--space-3) var(--space-4);
    flex-direction: column-reverse;
    gap: var(--space-2);
  }
  .visitor-form-footer .btn { width: 100%; }
}

/* Readonly banner */
.readonly-banner {
  background: #FEF9E7;
  border: 1px solid #FAD7A0;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-warning-dark);
  margin-bottom: var(--space-5);
}

/* Duplicate warning modal */
.duplicate-modal {
  max-width: 440px;
}

/* Host Autocomplete dropdown */
.host-autocomplete-wrap {
  position: relative;
}

.host-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  animation: slideDown 150ms ease;
}

.host-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: var(--font-size-sm);
}

.host-option:hover { background: var(--color-primary-light); }
.host-option__name { font-weight: 600; color: var(--color-text); }
.host-option__role { font-size: var(--font-size-xs); color: var(--color-text-secondary); }

/* =====================================================
   Visitor Type Segmented Control (special wider version)
   ===================================================== */
.visitor-type-control {
  display: flex;
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--color-border);
}

.visitor-type-control input { position: absolute; opacity: 0; width: 0; height: 0; }

.visitor-type-control label {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: calc(var(--radius-md) - 2px);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.visitor-type-control input:checked + label {
  background: white;
  color: var(--color-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  font-weight: 600;
}
