/* ============================================
   CalendarApp — Minimalist Scheduling UI
   ============================================ */

/* --- Custom Properties --- */
:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-accent: #10b981;
  --color-accent-hover: #059669;
  --color-bg: #ffffff;
  --color-bg-alt: #f8fafc;
  --color-bg-hover: #f1f5f9;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  --color-border: #e2e8f0;
  --color-border-focus: var(--color-primary);
  --color-error: #ef4444;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --transition: 200ms ease;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-primary-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { list-style: none; }

/* --- Utility --- */
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-center { text-align: center; }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* --- Loading Spinner --- */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  min-height: 120px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px;
  font-size: .9375rem; font-weight: 500;
  border: none; border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-accent { background: var(--color-accent); color: #fff; }
.btn-accent:hover { background: var(--color-accent-hover); }
.btn-outline {
  background: transparent; color: var(--color-primary);
  border: 1.5px solid var(--color-border);
}
.btn-outline:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.btn-ghost { background: transparent; color: var(--color-text-secondary); }
.btn-ghost:hover { background: var(--color-bg-hover); }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-sm { padding: 6px 14px; font-size: .8125rem; }
.btn-lg { padding: 14px 32px; font-size: 1.0625rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Forms --- */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: .875rem; font-weight: 500; color: var(--color-text-secondary);
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: .9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-input.error { border-color: var(--color-error); }
.form-error { font-size: .8125rem; color: var(--color-error); margin-top: 4px; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--color-primary); }

/* --- Cards --- */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-clickable { cursor: pointer; }
.card-clickable:hover { transform: translateY(-2px); }
.card h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 8px; }
.card p { color: var(--color-text-secondary); font-size: .9375rem; }
.card-meta { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: .8125rem; color: var(--color-text-muted); }

/* --- Badge --- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; font-size: .75rem; font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--color-primary-light); color: var(--color-primary);
}
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--color-border); }
th { font-size: .8125rem; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }
td { font-size: .9375rem; }
tr:hover td { background: var(--color-bg-alt); }

/* ============================================
   PUBLIC LAYOUT
   ============================================ */
.public-header {
  padding: 20px 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}
.public-header .container { display: flex; align-items: center; gap: 12px; }
.public-header .brand-logo { width: 36px; height: 36px; border-radius: var(--radius-sm); object-fit: cover; }
.public-header .brand-name { font-size: 1.125rem; font-weight: 600; color: var(--color-text); }
.public-main { padding: 48px 0 80px; min-height: calc(100vh - 140px); }
.public-footer {
  padding: 24px 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: .8125rem; color: var(--color-text-muted);
}

/* --- Session Types Grid --- */
.session-types-grid {
  display: grid; gap: 20px;
  grid-template-columns: 1fr;
}
.session-type-card { border-left: 4px solid var(--color-primary); }
.session-type-card .duration {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .8125rem; color: var(--color-primary); font-weight: 500;
}
.session-type-card .meeting-type { font-size: .8125rem; color: var(--color-text-muted); }

/* --- Booking Flow --- */
.booking-steps { display: flex; gap: 8px; margin-bottom: 32px; }
.booking-step {
  flex: 1; height: 4px; border-radius: var(--radius-full);
  background: var(--color-border);
  transition: background var(--transition);
}
.booking-step.active { background: var(--color-primary); }
.booking-step.done { background: var(--color-accent); }

.step-panel { display: none; animation: fadeIn .3s ease; }
.step-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* --- Calendar --- */
.calendar-widget { max-width: 420px; margin: 0 auto; }
.calendar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.calendar-header h2 { font-size: 1.0625rem; font-weight: 600; }
.calendar-nav {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: var(--radius-full);
  justify-content: center; color: var(--color-text-secondary);
  transition: background var(--transition);
}
.calendar-nav:hover { background: var(--color-bg-hover); }

.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  text-align: center;
}
.calendar-grid .day-label {
  font-size: .75rem; font-weight: 600;
  color: var(--color-text-muted);
  padding: 8px 0;
  text-transform: uppercase;
}
.calendar-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: .875rem; border-radius: var(--radius-full);
  cursor: default; color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
  border: none; background: none;
}
.calendar-day.available {
  color: var(--color-text); font-weight: 600; cursor: pointer;
  background: var(--color-accent);
  color: #fff;
  border-radius: var(--radius-full);
}
.calendar-day.available:hover {
  background: var(--color-primary);
  color: #fff;
}
.calendar-day.selected {
  background: var(--color-primary); color: #fff; font-weight: 600;
}
.calendar-day.today { box-shadow: inset 0 0 0 2px var(--color-primary-light); }
.calendar-day.other-month { opacity: .3; }

/* --- Time Slots --- */
.time-slots-container { margin-top: 24px; }
.time-slots-title { font-size: .9375rem; font-weight: 500; margin-bottom: 12px; color: var(--color-text-secondary); }
.time-slots-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px;
}
.time-slot {
  padding: 10px 8px;
  text-align: center; font-size: .875rem; font-weight: 500;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg);
  cursor: pointer;
  transition: all var(--transition);
}
.time-slot:hover { border-color: var(--color-primary); color: var(--color-primary); }
.time-slot.selected { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* --- Booking Form --- */
.booking-form { max-width: 480px; }
.booking-summary {
  padding: 20px; margin-bottom: 24px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
  font-size: .9375rem;
}
.booking-summary dt { font-weight: 500; color: var(--color-text-secondary); font-size: .8125rem; margin-top: 12px; }
.booking-summary dt:first-child { margin-top: 0; }
.booking-summary dd { font-weight: 600; }

/* --- Confirmation --- */
.confirmation-card {
  text-align: center; max-width: 500px; margin: 0 auto;
  padding: 48px 32px;
}
.confirmation-icon {
  width: 64px; height: 64px; margin: 0 auto 20px;
  border-radius: 50%; background: #dcfce7;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}
.confirmation-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.confirmation-details { text-align: left; margin-top: 28px; }
.confirmation-details dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }

/* ============================================
   ADMIN LAYOUT
   ============================================ */
.admin-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--color-bg-alt);
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}
.sidebar-brand {
  padding: 20px 24px;
  font-size: 1.0625rem; font-weight: 700;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  font-size: .9375rem; font-weight: 500;
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  transition: background var(--transition), color var(--transition);
}
.sidebar-nav a:hover { background: var(--color-bg-hover); color: var(--color-text); }
.sidebar-nav a.active { background: var(--color-primary-light); color: var(--color-primary); }
.sidebar-nav .nav-icon { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
}

/* Main content */
.admin-main {
  flex: 1; margin-left: var(--sidebar-width);
  display: flex; flex-direction: column;
}
.admin-topbar {
  height: var(--topbar-height);
  padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky; top: 0; z-index: 50;
}
.admin-topbar h1 { font-size: 1.125rem; font-weight: 600; }
.admin-topbar-actions { display: flex; align-items: center; gap: 12px; }
.admin-content { flex: 1; padding: 32px; }

/* Mobile toggle */
.sidebar-toggle {
  display: none; background: none; border: none; cursor: pointer;
  width: 40px; height: 40px; font-size: 1.25rem; color: var(--color-text);
  align-items: center; justify-content: center;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3);
  z-index: 90;
}

/* --- Admin Dashboard --- */
.stats-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 32px; }
.stat-card { padding: 24px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--color-text); }
.stat-card .stat-label { font-size: .8125rem; color: var(--color-text-muted); margin-top: 4px; }

/* --- Admin Availability Grid --- */
.availability-grid {
  display: grid; grid-template-columns: auto repeat(7, 1fr); gap: 1px;
  background: var(--color-border); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); overflow: hidden;
}
.availability-grid .cell {
  background: var(--color-bg); padding: 12px; text-align: center;
  font-size: .8125rem;
}
.availability-grid .cell-header {
  background: var(--color-bg-alt); font-weight: 600;
  color: var(--color-text-secondary); font-size: .75rem; text-transform: uppercase;
}
.availability-grid .cell-time { font-weight: 500; color: var(--color-text-muted); font-size: .8125rem; }
.availability-slot {
  border: none; background: none; width: 100%; height: 100%;
  cursor: pointer; border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.availability-slot:hover { background: var(--color-primary-light); }
.availability-slot.active { background: var(--color-primary); }

/* --- Filters Bar --- */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 24px;
}
.filters-bar .form-input,
.filters-bar .form-select { width: auto; min-width: 160px; padding: 8px 12px; font-size: .875rem; }

/* --- Modal --- */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 200;
  align-items: center; justify-content: center;
  animation: fadeIn .2s ease;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--color-bg); border-radius: var(--radius-lg);
  padding: 32px; width: 90%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-header h2 { font-size: 1.25rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.25rem; color: var(--color-text-muted); padding: 4px; }
.modal-close:hover { color: var(--color-text); }
.modal-footer { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* --- Alert/Toast --- */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 300;
  padding: 14px 20px; border-radius: var(--radius-md);
  background: var(--color-text); color: #fff;
  font-size: .9375rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn .3s ease, fadeOut .3s ease 3.7s;
  pointer-events: auto;
}
.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-error); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-8px); } }

/* --- Empty State --- */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--color-text-muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9375rem; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 480px) {
  .session-types-grid { grid-template-columns: repeat(2, 1fr); }
  .time-slots-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  .session-types-grid { grid-template-columns: repeat(2, 1fr); }
  .booking-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
}

@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex; }
  .admin-main { margin-left: 0; }
  .admin-content { padding: 20px 16px; }
  .admin-topbar { padding: 0 16px; }
}

@media (min-width: 1024px) {
  .session-types-grid { grid-template-columns: repeat(3, 1fr); }
  .container { padding: 0 32px; }
}
