/* popups.css v3.1.0 — Apple-inspired popup modals */
/* Compact, centered, no-scroll, frosted backdrop */

/* ===== Universal popup backdrop ===== */
.popup-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99998;
  animation: backdropIn 0.2s ease;
}
.popup-backdrop.visible {
  display: block;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== Base popup container ===== */
.popup {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: #ffffff;
  border-radius: 18px;
  padding: 0;
  width: 380px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  box-sizing: border-box;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.22),
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
  z-index: 99999;
  opacity: 0;
  animation: popupIn 0.25s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

@keyframes popupIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ===== Popup header ===== */
.popup h2 {
  background: linear-gradient(135deg, #003d22 0%, #006838 60%, #00824a 100%);
  color: #fff;
  padding: 18px 44px 18px 20px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  border-radius: 18px 18px 0 0;
  letter-spacing: -0.015em;
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

/* ===== Popup body — add padding via a wrapper approach ===== */
/* Since we can't change HTML, use padding on the popup itself after h2 */
.popup > *:not(h2):not(button):not(.popup-actions):not(.popup-body) {
  margin-left: 20px;
  margin-right: 20px;
}

/* Dedicated body wrapper — used by appointment & my-appointments popups */
.popup .popup-body {
  padding: 18px 20px 4px;
}

/* First element after h2 gets top spacing (legacy popups without .popup-body) */
.popup h2 + *:not(.popup-body) {
  margin-top: 16px !important;
}

/* ===== Form field groups (label + input pairs) ===== */
.popup .form-group {
  margin-bottom: 14px;
}
.popup .form-group:last-child {
  margin-bottom: 0;
}

/* Legacy inline-styled groups */
.popup div[style*="margin-bottom"] {
  margin-left: 20px !important;
  margin-right: 20px !important;
}

/* ===== Labels ===== */
.popup label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 11px;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.popup label .required {
  color: #ef4444;
  font-weight: 700;
  margin-left: 2px;
}

/* ===== Form inputs inside popups ===== */
.popup input,
.popup select,
.popup textarea {
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 0;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #f9fafb;
  color: #111827;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.popup textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.45;
}

/* Custom select chevron */
.popup select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
  cursor: pointer;
}
.popup select:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.popup input:hover,
.popup select:hover:not(:disabled),
.popup textarea:hover {
  border-color: #d1d5db;
  background: #f3f4f6;
}

.popup input:focus,
.popup select:focus,
.popup textarea:focus {
  outline: none;
  border-color: #00b386;
  box-shadow: 0 0 0 3px rgba(0, 179, 134, 0.15);
  background: #ffffff;
}

.popup input::placeholder,
.popup textarea::placeholder {
  color: #9ca3af;
}

/* ===== Field hint text (helper under input) ===== */
.popup .field-hint {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.35;
  color: #9ca3af;
  letter-spacing: 0;
  text-transform: none;
}

.popup small {
  font-size: 11.5px;
  color: #9ca3af;
}

/* ===== Action buttons ===== */
.popup .popup-actions,
.popup div[style*="display: flex"][style*="gap"] {
  display: flex;
  gap: 10px;
  margin: 18px 20px 20px !important;
  padding-top: 14px;
  border-top: 1px solid #f1f3f5;
}

.popup .popup-actions .btn-primary {
  flex: 1 1 auto;
}
.popup .popup-actions .btn-secondary {
  flex: 0 0 auto;
}

.popup button {
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
  letter-spacing: -0.01em;
}

.popup button:active {
  transform: scale(0.97);
}

/* Named primary/secondary classes (used by appointment popup) */
.popup .btn-primary {
  background: linear-gradient(135deg, #004225 0%, #006838 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 66, 37, 0.25);
}
.popup .btn-primary:hover {
  box-shadow: 0 6px 16px rgba(0, 66, 37, 0.32);
}
.popup .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.popup .btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}
.popup .btn-secondary:hover {
  background: #e5e7eb;
}

/* Primary popup button */
.popup button:first-child:not([style*="background: #6c757d"]):not([style*="position: absolute"]):not([onclick*="cancel"]):not([onclick*="skip"]):not([onclick*="reset"]) {
  background: linear-gradient(135deg, #004225 0%, #006838 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 66, 37, 0.25);
}

.popup button:first-child:not([style*="background: #6c757d"]):not([style*="position: absolute"]):not([onclick*="cancel"]):not([onclick*="skip"]):not([onclick*="reset"]):hover {
  box-shadow: 0 4px 14px rgba(0, 66, 37, 0.35);
}

/* Cancel/secondary button override */
.popup button[style*="background: #6c757d"] {
  background: #f3f4f6 !important;
  color: #374151 !important;
  box-shadow: none;
  border: 1px solid #e5e7eb;
}

.popup button[style*="background: #6c757d"]:hover {
  background: #e5e7eb !important;
}

/* ===== Forgot password link ===== */
.popup a {
  color: #00b386;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.popup a:hover {
  color: #009973;
}

/* ===== Exit confirmation popup ===== */
.exit-popup {
  text-align: center;
  max-width: 280px;
}
.popup.exit-popup h2 {
  font-size: var(--text-lg, 17px);
  padding: var(--space-5, 20px) var(--space-5, 20px) var(--space-3, 12px);
  background: transparent;
  color: var(--color-neutral-900, #111827);
}
.popup.exit-popup p {
  padding: 0 var(--space-5, 20px);
  color: var(--color-neutral-500, #6b7280);
  font-size: var(--text-sm, 13px);
  margin: 0 0 var(--space-5, 20px);
}
.popup.exit-popup .popup-actions button:first-child {
  background: var(--color-error, #dc2626);
}
.popup.exit-popup .popup-actions button:first-child:hover {
  background: #b91c1c;
}

/* ===== Dark mode ===== */
[data-theme="dark"] .popup {
  background: #2a2a2a;
  color: #f3f3f3;
}
[data-theme="dark"] .popup h2 {
  background: #003319;
}
[data-theme="dark"] .popup input,
[data-theme="dark"] .popup select,
[data-theme="dark"] .popup textarea {
  background: #333;
  border-color: #444;
  color: #f3f3f3;
}
[data-theme="dark"] .popup input:focus,
[data-theme="dark"] .popup select:focus,
[data-theme="dark"] .popup textarea:focus {
  border-color: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1);
}
[data-theme="dark"] .popup label {
  color: #ccc;
}
[data-theme="dark"] .popup .field-hint {
  color: #888;
}

.exit-popup p {
  margin-bottom: 16px;
  font-weight: 500;
  color: #374151;
}

/* ===== Close button (X) on popups ===== */
.popup .popup-close,
.popup button[aria-label="Close"],
.popup button[aria-label*="Close"] {
  position: absolute !important;
  top: 12px !important;
  right: 12px !important;
  background: rgba(255, 255, 255, 0.18) !important;
  border: none !important;
  color: #fff !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 50% !important;
  font-size: 18px !important;
  line-height: 1 !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  z-index: 2;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.15s, transform 0.15s;
  box-shadow: none;
}

.popup .popup-close:hover,
.popup button[aria-label="Close"]:hover,
.popup button[aria-label*="Close"]:hover {
  background: rgba(255, 255, 255, 0.32) !important;
  transform: rotate(90deg);
}

/* ===== Star rating refinement ===== */
.star-rating {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 32px;
  user-select: none;
  padding: 0 20px;
}

.star {
  color: #e5e7eb;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease;
}

.star:hover,
.star.active {
  color: #fbbf24;
  transform: scale(1.15);
}

.star.active {
  text-shadow: 0 2px 8px rgba(251, 191, 36, 0.4);
}

/* ===== Dark mode ===== */
[data-theme="dark"] .popup-backdrop {
  background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .popup,
#chat-container[data-theme="dark"] .popup {
  background: #1e1e1e;
  color: #f3f3f3;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .popup h2,
#chat-container[data-theme="dark"] .popup h2 {
  background: linear-gradient(135deg, #003319 0%, #004d2e 100%);
}

[data-theme="dark"] .popup input,
[data-theme="dark"] .popup select,
[data-theme="dark"] .popup textarea,
#chat-container[data-theme="dark"] .popup input,
#chat-container[data-theme="dark"] .popup select,
#chat-container[data-theme="dark"] .popup textarea {
  background: #2a2a2a;
  border-color: #404040;
  color: #f3f3f3;
}

[data-theme="dark"] .popup input:focus,
[data-theme="dark"] .popup select:focus,
[data-theme="dark"] .popup textarea:focus {
  border-color: #00b386;
  background: #333;
}

[data-theme="dark"] .popup label {
  color: #9ca3af;
}

[data-theme="dark"] .popup button[style*="background: #6c757d"] {
  background: #333 !important;
  color: #e5e7eb !important;
  border-color: #444 !important;
}

[data-theme="dark"] .popup .btn-secondary,
#chat-container[data-theme="dark"] .popup .btn-secondary {
  background: #2a2a2a;
  color: #e5e7eb;
  border-color: #404040;
}
[data-theme="dark"] .popup .btn-secondary:hover {
  background: #333;
}

[data-theme="dark"] .popup .field-hint,
#chat-container[data-theme="dark"] .popup .field-hint {
  color: #8a8a8a;
}

[data-theme="dark"] .popup label .required {
  color: #f87171;
}

[data-theme="dark"] .popup .popup-actions,
[data-theme="dark"] .popup div[style*="display: flex"][style*="gap"] {
  border-top-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .popup select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%239ca3af' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

/* ===== Responsive — smaller screens get tighter popups ===== */
@media (max-width: 768px) {
  .popup {
    width: calc(100% - 20px);
    max-height: calc(100% - 20px);
    border-radius: 16px;
  }

  .popup h2 {
    padding: 16px 44px 16px 16px;
    font-size: 15px;
    border-radius: 16px 16px 0 0;
  }

  .popup .popup-body {
    padding: 16px 16px 4px;
  }

  .popup input,
  .popup select,
  .popup textarea {
    padding: 11px 12px;
    font-size: 14px;
  }

  .popup button {
    padding: 11px 14px;
    font-size: 13.5px;
  }

  .popup > *:not(h2):not(button):not(.popup-actions):not(.popup-body) {
    margin-left: 16px;
    margin-right: 16px;
  }

  .popup div[style*="margin-bottom"] {
    margin-left: 16px !important;
    margin-right: 16px !important;
  }

  .popup .popup-actions,
  .popup div[style*="display: flex"][style*="gap"] {
    margin: 14px 16px 16px !important;
  }

  .popup .form-group {
    margin-bottom: 12px;
  }
}
