/* ========================================
   SHARED / GLOBAL STYLES
======================================== */

/* ----- Page Structure ----- */
.page-container {
  position: relative;
  max-width: 800px;
  margin: 2rem auto;
  padding: 1rem;
  background-color: var(--portalThemeColor2); /* white */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
}

.form-card {
  background-color: var(--portalThemeColor2); /* white */
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  position: relative;
}

/* ----- Typography ----- */
.form-card h2 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--portalThemeColor4); /* deep navy */
  padding-bottom: 0.5rem;
}

.form-card h3 {
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--portalThemeColor4);
}

.note-text {
  color: #555;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--portalThemeColor8);
  padding-bottom: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ----- Form Elements ----- */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  color: var(--portalThemeColor4);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="date"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  color: var(--portalThemeColor4);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  color: var(--portalThemeColor4);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--portalThemeColor8);
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20stroke='%23333'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='2'%20viewBox='0%200%2024%2024'%3E%3Cpath%20d='M6%209l6%206%206-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem 1rem;
  padding-right: 2rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--portalThemeColor4);
  box-shadow: 0 0 0 3px rgba(12, 28, 74, 0.15);
}

.form-group input::placeholder {
  color: #999;
}

/* Checkbox Group */
.checkbox-group {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.checkbox-group input[type="checkbox"] {
  transform: scale(1.2);
  margin: 0;
  cursor: pointer;
}

.checkbox-group label {
  display: inline;
  margin-bottom: 0;
}

/* ----- Loading States ----- */

/* Calendar content area container */
.calendar-content-area {
  margin-top: 20px;
  min-height: 400px; /* Ensure consistent height during state transitions */
}

/* Loading state styles */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background-color: #f8f8f8;
  border-radius: 8px;
  text-align: center;
  min-height: 300px;
}

.loading-spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--portalThemeColor4); /* deep navy */
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

.loading-message {
  font-size: 1rem;
  color: var(--portalThemeColor4);
  font-weight: 500;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Standard loading overlay (for patient registration) */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(248, 248, 248, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Dimming effect when spinner is active */
.no-interactions {
  opacity: 0.5;
  pointer-events: none;
}

/* ----- Button Styles ----- */
.btn {
  padding: 0.625rem 1rem;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background-color: var(--portalThemeColor4); /* deep navy */
  color: var(--portalThemeColor2); /* white */
}

.btn-primary:hover {
  background-color: var(--portalThemeColor10);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
}

.btn-primary:disabled {
  background-color: #a8b2c7;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: #f1f1f1;
  color: var(--portalThemeColor4);
}

.btn-secondary:hover {
  background-color: #e1e1e1;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
}

.button-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ----- Modal Overlay & Content ----- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--portalThemeColor2); /* white */
  border-radius: 8px;
  max-width: 600px;
  padding: 24px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
  margin-top: 0;
  color: var(--portalThemeColor4);
}

#confirmationTable {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

#confirmationTable td {
  padding: 8px;
  border-bottom: 1px solid var(--portalThemeColor8);
}

#confirmationTable td:first-child {
  font-weight: bold;
  width: 40%;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 1rem;
}

/* ========================================
   NEW PATIENT FORM SPECIFIC STYLES
======================================== */

/* Responsible Party Section */
#responsiblePartySection {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--portalThemeColor8);
  border-radius: 6px;
  background-color: var(--portalThemeColor1);
}

#responsiblePartySection h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--portalThemeColor4);
  border-bottom: 1px solid var(--portalThemeColor8);
  padding-bottom: 0.5rem;
}

/* ========================================
   BOOK APPOINTMENT SPECIFIC STYLES
======================================== */

/* Booking Header */
.booking-header {
  margin-bottom: 1.5rem;
}

/* Start Date Picker */
.start-date-picker {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.start-date-picker label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--portalThemeColor4);
}

.start-date-picker input[type="date"] {
  padding: 0.5rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Booking Container & Calendar */
.booking-container {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .booking-container {
    flex-direction: column;
  }
}

.calendar-column {
  flex: 1;
}

.month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--portalThemeColor4);
}

.nav-btn {
  background-color: var(--portalThemeColor4);
  color: var(--portalThemeColor2); /* white */
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.nav-btn:hover {
  background-color: var(--portalThemeColor10);
}

/* Calendar Grid */
.calendar-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.day-name-row,
.calendar-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  text-align: center;
}

.day-name {
  font-weight: bold;
  color: #777;
}

.calendar-day {
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  color: var(--portalThemeColor4);
}

.calendar-day:hover {
  background-color: #eee;
}

.out-of-month {
  color: transparent;
  background-color: transparent;
  pointer-events: none;
  border: none;
}

.available {
  background-color: var(--portalThemeColor4); /* deep navy */
  color: var(--portalThemeColor2); /* white */
}

.available:hover {
  background-color: var(--portalThemeColor10);
}

.unavailable {
  background-color: #f7f7f7;
  color: #999;
  cursor: default;
}

/* Times Column & Slots - Improved styling */
.times-column {
  flex: 1;
  border-left: 1px solid #eee;
  padding-left: 1.5rem;
}

.selected-date-header {
  margin-bottom: 1.5rem;
}

.selected-date-header h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
  color: var(--portalThemeColor4);
}

.selected-date-display {
  font-size: 1.1rem;
  color: var(--portalThemeColor7); /* gold accent */
  font-weight: 600;
}

.timeslots-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.slot {
  background-color: #f7f7f7;
  padding: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--portalThemeColor4);
  text-align: center;
  font-size: 1.1rem;
  border: 1px solid #e6e6e6;
}

.slot:hover {
  background-color: #e8e8e8;
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.slot.selected {
  border: 2px solid var(--portalThemeColor4);
  background-color: var(--portalThemeColor4);
  color: var(--portalThemeColor2);
}

/* For responsive design */
@media (max-width: 768px) {
  .times-column {
    border-left: none;
    padding-left: 0;
    margin-top: 2rem;
    border-top: 1px solid #eee;
    padding-top: 1.5rem;
  }
}

/* Action Buttons for Appointment */
.action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
}