/* ============================================================
   Booking Engine — Stylesheet (vanilla CSS, no framework)
   Responsive design, mobile-first approach.
   ============================================================ */

:root {
  --primary: #4a90d9;
  --primary-dark: #357abd;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --border: #dcdde1;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* --- Layout --- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  margin-left: 24px;
}

.nav-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.app-content { padding: 16px; max-width: 1400px; margin: 0 auto; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #c8c9cc; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* --- Cards --- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* --- Forms --- */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-light);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.form-textarea { resize: vertical; min-height: 60px; }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px;
}

/* --- Agenda / Calendar --- */
.agenda-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.agenda-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agenda-date { font-size: 16px; font-weight: 600; }

.calendar-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Weekly view: employee columns + time rows */
.calendar-weekly {
  grid-template-columns: 60px repeat(auto-fill, minmax(180px, 1fr));
}

.calendar-header-cell {
  background: var(--surface);
  padding: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}

.time-label {
  background: var(--surface);
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-light);
  text-align: right;
  border-right: 1px solid var(--border);
  height: 60px; /* matches slot height */
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}

.calendar-cell {
  background: var(--surface);
  min-height: 60px;
  position: relative;
  cursor: pointer;
  transition: background 0.1s;
}

.calendar-cell:hover { background: #f0f4ff; }

/* Booking blocks within cells */
.booking-block {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 11px;
  color: white;
  overflow: hidden;
  cursor: pointer;
  z-index: 10;
}

.booking-block .booking-client { font-weight: 600; }
.booking-block .booking-service { opacity: 0.85; }

/* Status colors */
.status-pending    { border-left: 3px solid var(--warning); }
.status-confirmed  { border-left: 3px solid var(--success); }
.status-cancelled  { border-left: 3px solid var(--danger); opacity: 0.6; }
.status-completed  { border-left: 3px solid #95a5a6; opacity: 0.7; }
.status-no_show    { border-left: 3px solid var(--danger); opacity: 0.5; }

/* --- Lists (employees, services, clients) --- */
.resource-list { display: flex; flex-direction: column; gap: 8px; }

.resource-item {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.resource-item-info { flex: 1; }
.resource-item-name { font-weight: 600; font-size: 15px; }
.resource-item-meta { font-size: 13px; color: var(--text-light); }

.resource-item-actions { display: flex; gap: 4px; }

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

/* --- Availability slots --- */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.slot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.slot-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(74, 144, 217, 0.2);
}

.slot-time { font-weight: 600; font-size: 14px; }
.slot-employee { font-size: 12px; color: var(--text-light); margin-top: 2px; }

/* --- Loading & Error states --- */
.loading, .error-state {
  text-align: center;
  padding: 40px 16px;
}

.loading { color: var(--text-light); }
.error-state { color: var(--danger); }

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

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

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-light);
}

/* --- Search bar --- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .app-header { flex-wrap: wrap; height: auto; padding: 8px; }
  .nav-tabs { margin-left: 0; margin-top: 4px; width: 100%; overflow-x: auto; }
  .nav-tab { padding: 6px 12px; font-size: 13px; white-space: nowrap; }
  .app-content { padding: 8px; }
  .modal { width: 95%; padding: 16px; }
  .resource-item { flex-direction: column; align-items: flex-start; gap: 8px; }
}
