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

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);

  --status-pending:   #f59e0b;
  --status-confirmed: #10b981;
  --status-cancelled: #ef4444;
  --status-completed: #6366f1;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
}
header h1 { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
header span { font-size: 0.8rem; color: var(--text-muted); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fee2e2; color: #ef4444; }
.btn-danger:hover { background: #fecaca; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

header .actions { margin-left: auto; display: flex; gap: 8px; }

/* ─── Calendar container ──────────────────────── */
main {
  flex: 1;
  padding: 20px 24px;
  overflow: auto;
}

#calendar-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: calc(100vh - 140px);
}

/* FullCalendar overrides */
.fc .fc-toolbar-title { font-size: 1rem; font-weight: 700; }
.fc .fc-button { background: var(--primary) !important; border-color: var(--primary) !important; text-transform: capitalize; font-size: 0.8rem; }
.fc .fc-button:hover { background: var(--primary-hover) !important; border-color: var(--primary-hover) !important; }
.fc .fc-button-active { background: var(--primary-hover) !important; }
.fc-event { cursor: pointer; border-radius: 4px !important; font-size: 0.78rem; }
.fc-event-title { font-weight: 600; }

/* ─── Status badge ────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-completed { background: #ede9fe; color: #4c1d95; }

/* ─── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  transform: translateY(16px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.3rem; line-height: 1;
  padding: 2px 6px; border-radius: 6px;
}
.modal-close:hover { background: var(--bg); }

.modal-body { display: flex; flex-direction: column; gap: 14px; }

.detail-row { display: flex; gap: 8px; font-size: 0.88rem; }
.detail-label { color: var(--text-muted); min-width: 110px; font-weight: 500; }
.detail-value { color: var(--text); }

.modal-footer { margin-top: 24px; display: flex; gap: 10px; justify-content: flex-end; }

/* ─── Form ────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); background: #fff; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ─── Chat widget ─────────────────────────────── */
#chat-toggle {
  position: fixed; bottom: 24px; right: 24px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 16px rgba(79,70,229,0.45);
  z-index: 200;
  transition: background 0.15s, transform 0.15s;
}
#chat-toggle:hover { background: var(--primary-hover); transform: scale(1.07); }

#chat-panel {
  position: fixed; bottom: 88px; right: 24px;
  width: 360px; height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex; flex-direction: column;
  z-index: 199;
  transform: translateY(16px) scale(0.96);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#chat-panel.open { opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }

.chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  border-radius: 16px 16px 0 0;
  background: var(--primary);
  color: #fff;
}
.chat-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.chat-header-info h3 { font-size: 0.9rem; font-weight: 700; }
.chat-header-info p  { font-size: 0.72rem; opacity: 0.8; }
.chat-header-close {
  margin-left: auto; background: none; border: none;
  color: rgba(255,255,255,0.8); cursor: pointer; font-size: 1.1rem;
  padding: 4px; border-radius: 6px;
}
.chat-header-close:hover { color: #fff; background: rgba(255,255,255,0.15); }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.45;
  word-break: break-word;
}
.msg-bot  { background: var(--bg); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }

.typing-indicator {
  display: flex; gap: 4px; align-items: center;
  padding: 10px 14px;
  background: var(--bg); border-radius: 14px; border-bottom-left-radius: 4px;
  align-self: flex-start; width: fit-content;
}
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

.chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: flex-end;
  border-radius: 0 0 16px 16px;
}
#chat-input {
  flex: 1; resize: none;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; font-size: 0.84rem;
  outline: none; max-height: 100px; overflow-y: auto;
  line-height: 1.4;
  font-family: inherit;
}
#chat-input:focus { border-color: var(--primary); }
#chat-send {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary); color: #fff;
  border: none; cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#chat-send:hover { background: var(--primary-hover); }
#chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Toast ───────────────────────────────────── */
#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: #1e293b; color: #fff;
  padding: 10px 20px; border-radius: 8px; font-size: 0.84rem;
  opacity: 0; transition: opacity 0.2s, transform 0.2s;
  pointer-events: none; z-index: 999;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Webhook config notice ───────────────────── */
#webhook-notice {
  background: #fef3c7; border: 1px solid #f59e0b;
  border-radius: 8px; padding: 10px 14px;
  font-size: 0.8rem; color: #92400e;
  margin: 0 24px 12px;
  display: none;
}
#webhook-notice.show { display: block; }
