/* ==========================================================================
   Lightbox — overlay dialogs (Book Appointment Form, etc.)
   ========================================================================== */

body.lightbox-open {
  overflow: hidden;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  overflow: hidden;
}

.lightbox-overlay[hidden] {
  display: none !important;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 640px);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
  background: var(--km-dark, #111);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: calc(var(--radius, 8px) + 4px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.lightbox-panel--form {
  width: min(100%, 720px);
}

.lightbox-panel--media {
  width: min(100%, min(96vw, 960px));
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.lightbox-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--km-white, #fff);
}

.lightbox-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: var(--radius, 8px);
  background: rgba(255, 255, 255, 0.08);
  color: var(--km-white, #fff);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition, 0.2s ease);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.lightbox-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* CRM / calendar media previews inside the shared lightbox shell */
.admin-crm-lightbox-media,
.admin-calendar-lightbox-media {
  display: grid;
  gap: 1rem;
}

.admin-crm-lightbox-media img,
.admin-crm-lightbox-media video,
.admin-calendar-lightbox-media img,
.admin-calendar-lightbox-media video {
  display: block;
  width: 100%;
  max-height: min(70vh, 720px);
  object-fit: contain;
  background: #000;
  border-radius: 0.35rem;
}

.lightbox-loading {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}

/* ── Form ─────────────────────────────────────────────────────────────── */

.lightbox-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lightbox-fieldset {
  margin: 0;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius, 8px);
}

.lightbox-legend {
  padding: 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
}

.lightbox-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
}

.lightbox-auth-buttons {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.btn-auth {
  width: 100%;
  justify-content: flex-start;
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--km-white, #fff);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.btn-auth:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-auth-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
}

.btn-auth-google .btn-auth-icon {
  background: #fff;
  color: #4285f4;
}

.btn-auth-facebook .btn-auth-icon {
  background: #1877f2;
  color: #fff;
}

.lightbox-auth-status {
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
}

.lightbox-auth-status.is-error {
  color: #ff8a8a;
}

.lightbox-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 540px) {
  .lightbox-form-grid {
    grid-template-columns: 1fr;
  }
}

.lightbox-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lightbox-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.lightbox-field input[type="text"],
.lightbox-field input[type="date"],
.lightbox-field input[type="time"],
.lightbox-field input[type="number"],
.lightbox-field input[type="file"],
.lightbox-field select,
.lightbox-field textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--km-white, #fff);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius, 8px);
}

.lightbox-field input[readonly] {
  opacity: 0.85;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.04);
}

.lightbox-field input:focus,
.lightbox-field select:focus,
.lightbox-field textarea:focus {
  outline: none;
  border-color: var(--km-red, #c41e3a);
  box-shadow: 0 0 0 2px rgba(196, 30, 58, 0.25);
}

.lightbox-field textarea {
  resize: vertical;
  min-height: 5rem;
}

.lightbox-field select option {
  color: #111;
  background: #fff;
}

.lightbox-image-preview {
  margin-top: 0.5rem;
  border-radius: var(--radius, 8px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  max-height: 180px;
}

.lightbox-image-preview img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
}

.lightbox-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}

.lightbox-form-actions .btn-secondary {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.9);
}

.lightbox-form-message {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius, 8px);
  font-size: 0.88rem;
}

.lightbox-form-message.is-error {
  background: rgba(196, 30, 58, 0.18);
  color: #ffb3bd;
  border: 1px solid rgba(196, 30, 58, 0.35);
}

.lightbox-form-message.is-success {
  background: rgba(46, 160, 67, 0.18);
  color: #9be9a8;
  border: 1px solid rgba(46, 160, 67, 0.35);
}
