/* ─── CSS Variables & Theme ─── */
:root {
  --primary: #2B6CB0;
  --primary-light: #4299E1;
  --primary-dark: #1A4971;
  --primary-bg: #EBF4FF;
  --secondary: #38A169;
  --secondary-light: #68D391;
  --accent: #805AD5;
  --danger: #E53E3E;
  --danger-light: #FED7D7;
  --warning: #D69E2E;
  --warning-light: #FEFCBF;
  --text: #2D3748;
  --text-light: #718096;
  --text-lighter: #A0AEC0;
  --bg: #F7FAFC;
  --bg-white: #FFFFFF;
  --border: #E2E8F0;
  --border-light: #EDF2F7;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}

/* ─── Reset & Base ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

/* ─── Typography ─── */
h1, h2, h3, h4 {
  line-height: 1.3;
  font-weight: 600;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

/* ─── Header ─── */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.15rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-link {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  transition: var(--transition);
}

.header-link:hover {
  background: rgba(255,255,255,0.15);
  color: white;
  border-color: rgba(255,255,255,0.5);
}

/* ─── Container ─── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-light);
}

.card-title {
  font-size: 1.1rem;
  color: var(--primary-dark);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-bg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Stepper ─── */
.stepper {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-lighter);
  position: relative;
}

.step:not(:last-child)::after {
  content: '';
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 0.75rem;
}

.step.active {
  color: var(--primary);
  font-weight: 600;
}

.step.completed {
  color: var(--secondary);
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--border-light);
  color: var(--text-lighter);
  flex-shrink: 0;
}

.step.active .step-number {
  background: var(--primary);
  color: white;
}

.step.completed .step-number {
  background: var(--secondary);
  color: white;
}

/* ─── Forms ─── */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-white);
  transition: var(--transition);
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.form-input::placeholder {
  color: var(--text-lighter);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--border-light);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #C53030;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary-light);
  color: var(--primary);
  background: var(--primary-bg);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1.05rem;
}

/* ─── Appointment Type Selection ─── */
.type-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.type-option {
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-white);
}

.type-option:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.type-option.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.type-option .type-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.type-option.selected .type-icon {
  background: var(--primary);
  color: white;
}

.type-option .type-name {
  font-weight: 500;
  font-size: 0.95rem;
}

.type-option .type-duration {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* ─── Calendar ─── */
.calendar {
  user-select: none;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.calendar-header h3 {
  font-size: 1rem;
  text-transform: capitalize;
}

.calendar-nav {
  display: flex;
  gap: 0.5rem;
}

.calendar-nav button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition);
}

.calendar-nav button:hover {
  background: var(--primary-bg);
  border-color: var(--primary-light);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-day-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  padding: 0.5rem 0;
  text-transform: uppercase;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  border-radius: var(--radius);
  cursor: default;
  color: var(--text-lighter);
  transition: var(--transition);
}

.calendar-day.available {
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  background: var(--primary-bg);
}

.calendar-day.available:hover {
  background: var(--primary-light);
  color: white;
}

.calendar-day.selected {
  background: var(--primary) !important;
  color: white !important;
  font-weight: 700;
}

.calendar-day.today {
  border: 2px solid var(--primary-light);
}

.calendar-day.other-month {
  opacity: 0.3;
}

/* ─── Time Slots ─── */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.5rem;
}

.slot {
  padding: 0.6rem 0.5rem;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  background: var(--bg-white);
}

.slot:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.slot.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.slot-period-label {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 600;
  margin: 0.75rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-light);
}

/* ─── Summary ─── */
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.95rem;
}

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

.summary-label {
  color: var(--text-light);
  font-weight: 500;
}

.summary-value {
  font-weight: 600;
  text-align: right;
}

/* ─── Confirmation ─── */
.confirmation-icon {
  text-align: center;
  margin-bottom: 1rem;
}

.confirmation-icon .icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #C6F6D5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.confirmation-message {
  text-align: center;
  margin-bottom: 1.5rem;
}

.confirmation-message h2 {
  color: var(--secondary);
  margin-bottom: 0.5rem;
}

/* ─── Alerts ─── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-error {
  background: var(--danger-light);
  color: #9B2C2C;
  border: 1px solid #FEB2B2;
}

.alert-success {
  background: #C6F6D5;
  color: #22543D;
  border: 1px solid #9AE6B4;
}

.alert-info {
  background: var(--primary-bg);
  color: var(--primary-dark);
  border: 1px solid #BEE3F8;
}

/* ─── Loading ─── */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 0.75rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Visibility ─── */
.hidden {
  display: none !important;
}

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

/* ─── Language Toggle ─── */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  cursor: pointer;
  user-select: none;
  border: 1.5px solid rgba(255,255,255,0.3);
  overflow: hidden;
  flex-shrink: 0;
  transition: var(--transition);
}

.lang-toggle:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.5);
}

.lang-option {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: rgba(255,255,255,0.6);
  transition: var(--transition);
}

.lang-option.active {
  background: rgba(255,255,255,0.95);
  color: var(--primary-dark);
  border-radius: 18px;
}

/* Login page override: darker toggle */
.login-container .lang-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--primary);
  border-color: var(--primary-light);
  z-index: 100;
}

.login-container .lang-toggle:hover {
  background: var(--primary-dark);
}

/* Admin sidebar toggle */
.admin-lang-toggle {
  display: flex;
  justify-content: center;
  padding: 0.75rem 1.25rem 0.5rem;
}

.admin-lang-toggle .lang-toggle {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

.admin-lang-toggle .lang-toggle:hover {
  background: rgba(255,255,255,0.2);
}

/* ─── Footer ─── */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-lighter);
  font-size: 0.8rem;
  margin-top: 2rem;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .container {
    padding: 1rem;
  }
  
  .card {
    padding: 1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stepper {
    padding: 0;
  }

  .step span:not(.step-number) {
    display: none;
  }

  .step:not(:last-child)::after {
    width: 24px;
    margin: 0 0.4rem;
  }

  .slots-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }

  .header h1 {
    font-size: 1.1rem;
  }

  h1 { font-size: 1.4rem; }
}

@media (min-width: 641px) {
  .type-grid {
    grid-template-columns: 1fr 1fr;
  }
}
