/* ═══════════════════════════════════════════
   CrossFitV6 — Agenda & Dashboard
   ═══════════════════════════════════════════ */

:root {
  --bg: #0f0f0f;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #ff6b35;
  --accent2: #ff8c00;
  --green: #22c55e;
  --green-bg: #16653433;
  --blue: #3b82f6;
  --blue-bg: #1d4ed833;
  --orange: #f59e0b;
  --orange-bg: #b4530933;
  --purple: #a855f7;
  --purple-bg: #7c3aed33;
  --red: #ef4444;
  --red-bg: #dc262633;
  --gray: #6b7280;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { 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);
  min-height: 100vh;
}

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

/* HEADER */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.header-left h1 { font-size: 1.4rem; font-weight: 700; }
.header-sub { font-size: 0.8rem; color: var(--text-muted); }

.header-center { display: flex; gap: 16px; }
.status-bar { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); }
.status-dot.paused { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.status-sep { color: var(--border); }

.header-right { display: flex; gap: 8px; }

/* BUTTONS */

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text);
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-card-hover); border-color: #444; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-icon { padding: 6px 10px; font-size: 0.9rem; }
.btn-pause { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); }
.btn-pause:hover { background: var(--orange); color: #fff; }
.btn-pause.active { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.btn-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }
.btn-close:hover { color: var(--text); }

.btn-filter { padding: 4px 10px; font-size: 0.78rem; }
.btn-filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* PAUSE BANNER */

.pause-banner {
  background: var(--orange-bg);
  border: 1px solid var(--orange);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}
.pause-banner.hidden { display: none; }

/* DASHBOARD */

.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* MAIN CONTENT */

.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .main-content { grid-template-columns: 1fr; }
  .header { flex-direction: column; gap: 12px; }
}

/* PANELS */

.calendar-panel, .list-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.panel-header h2 { font-size: 1.1rem; flex: 1; }
.filter-btns { display: flex; gap: 4px; }

/* CALENDAR GRID */

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

.calendar-grid .day-header {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 8px 4px;
  font-weight: 600;
}

.calendar-grid .day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  position: relative;
  transition: background 0.1s;
}
.calendar-grid .day-cell:hover { background: var(--bg-card-hover); }
.calendar-grid .day-cell.today { background: var(--orange-bg); font-weight: 700; }
.calendar-grid .day-cell.selected { background: var(--accent); color: #fff; }
.calendar-grid .day-cell.other-month { color: var(--text-muted); opacity: 0.4; }
.calendar-grid .day-cell.weekend { color: var(--orange); }

.day-dots { display: flex; gap: 2px; margin-top: 2px; }
.day-dot {
  width: 5px; height: 5px; border-radius: 50%;
}
.day-dot.exp { background: var(--green); }
.day-dot.mensal { background: var(--blue); }
.day-dot.dropin { background: var(--purple); }
.day-dot.cancelled { background: var(--red); }

/* LEGEND */

.legend { display: flex; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--text-muted); }
.legend-color { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-color.exp { background: var(--green); }
.legend-color.mensal { background: var(--blue); }
.legend-color.dropin { background: var(--purple); }
.legend-color.cancelled { background: var(--red); }

/* APPOINTMENT LIST */

.appointment-list { min-height: 80px; }

.appointment-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
}
.appointment-card:hover { background: var(--bg-card-hover); }

.appt-info { flex: 1; }
.appt-name { font-weight: 600; font-size: 0.9rem; }
.appt-detail { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.appt-badges { display: flex; gap: 4px; align-items: center; }
.badge {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 12px; font-weight: 500;
}
.badge-exp { background: var(--green-bg); color: var(--green); }
.badge-mensal { background: var(--blue-bg); color: var(--blue); }
.badge-trimestral { background: var(--orange-bg); color: var(--orange); }
.badge-anual { background: var(--purple-bg); color: var(--purple); }
.badge-dropin { background: var(--purple-bg); color: var(--purple); }
.badge-confirmed { background: var(--green-bg); color: var(--green); }
.badge-cancelled { background: var(--red-bg); color: var(--red); }
.badge-completed { background: var(--blue-bg); color: var(--blue); }
.badge-whatsapp { background: var(--green-bg); color: var(--green); }
.badge-web { background: var(--blue-bg); color: var(--blue); }

.appt-actions { display: flex; gap: 4px; }
.appt-actions button {
  background: none; border: none; cursor: pointer; padding: 4px 8px;
  font-size: 0.8rem; color: var(--text-muted); border-radius: 4px;
}
.appt-actions button:hover { color: var(--text); background: var(--bg-card); }
.appt-actions .btn-cancel:hover { color: var(--red); }

.empty-msg { color: var(--text-muted); font-size: 0.85rem; text-align: center; padding: 24px; }

/* RECENT SECTION */

.recent-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.recent-section h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; }

/* CHARTS */

.chart-section, .type-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.chart-section h3, .type-section h3 { font-size: 0.95rem; margin-bottom: 12px; }

.mini-chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; overflow-x: auto; }
.chart-bar {
  flex: 1; min-width: 8px; border-radius: 2px 2px 0 0;
  background: var(--accent); position: relative;
}
.chart-bar:hover { opacity: 0.8; }
.chart-bar .chart-tooltip {
  display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; font-size: 0.65rem; padding: 2px 6px;
  border-radius: 4px; white-space: nowrap;
}
.chart-bar:hover .chart-tooltip { display: block; }

.chart-labels { display: flex; gap: 2px; margin-top: 4px; font-size: 0.6rem; color: var(--text-muted); overflow-x: hidden; }
.chart-labels span { flex: 1; min-width: 8px; text-align: center; }

.type-bars { display: flex; flex-direction: column; gap: 8px; }
.type-bar-row { display: flex; align-items: center; gap: 8px; }
.type-bar-label { font-size: 0.8rem; width: 160px; text-align: right; }
.type-bar-track { flex: 1; height: 24px; background: var(--bg); border-radius: 12px; overflow: hidden; }
.type-bar-fill { height: 100%; border-radius: 12px; transition: width 0.3s; }
.type-bar-fill.exp { background: var(--green); }
.type-bar-fill.mensal { background: var(--blue); }
.type-bar-fill.trimestral { background: var(--orange); }
.type-bar-fill.anual { background: var(--purple); }
.type-bar-fill.dropin { background: var(--gray); }
.type-bar-count { font-size: 0.8rem; font-weight: 600; min-width: 30px; }

/* MODAL */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 480px; box-shadow: var(--shadow);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h2 { font-size: 1.1rem; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 0.9rem;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent);
}

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

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* RESPONSIVE */

@media (max-width: 600px) {
  .dashboard { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 1.2rem; }
  .header { flex-direction: column; align-items: flex-start; }
}

/* QR CODE PANEL */

.bottom-panels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

@media (max-width: 1200px) {
  .bottom-panels { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .bottom-panels { grid-template-columns: 1fr; }
}

/* ALERT TOAST */

.alert-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  background: #1a0a0a;
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 360px;
  max-width: 500px;
  box-shadow: 0 0 30px rgba(239,68,68,0.3);
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.alert-toast.hidden { display: none; }
.alert-toast-icon { font-size: 1.6rem; animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}
.alert-toast-body { flex: 1; }
.alert-toast-body strong { display: block; color: var(--red); font-size: 0.9rem; }
.alert-toast-body span { font-size: 0.78rem; color: var(--text-muted); }
.alert-toast-btn {
  background: var(--red); color: #fff; border: none;
  padding: 6px 14px; border-radius: var(--radius); cursor: pointer;
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.alert-toast-btn:hover { opacity: 0.9; }
.alert-toast-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; padding: 4px;
}
.alert-toast-close:hover { color: #fff; }

/* TEST PANEL */

.test-panel {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.test-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}
@media (max-width: 800px) {
  .test-body { grid-template-columns: 1fr; }
}
.test-input-row {
  display: flex;
  gap: 8px;
}
.test-input-row input { flex: 1; }
.test-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  align-items: center;
}
.test-quick-btns span {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 4px;
}
.test-right {
  display: flex;
  flex-direction: column;
}
.test-right label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.test-response {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 100px;
  white-space: pre-wrap;
  font-size: 0.85rem;
  line-height: 1.5;
}
.test-meta {
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.qr-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.qr-status-badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
  background: var(--orange-bg);
  color: var(--orange);
}
.qr-status-badge.connected {
  background: var(--green-bg);
  color: var(--green);
}

.qr-body {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.qr-container {
  flex-shrink: 0;
  width: 180px;
  height: 180px;
  background: #fff;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.qr-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  color: #333;
}
.qr-placeholder span {
  font-size: 2rem;
}
.qr-placeholder small {
  font-size: 0.75rem;
  color: #666;
}

.qr-instructions {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.qr-instructions strong {
  color: var(--text);
}
.qr-instructions ol {
  margin: 6px 0 0 16px;
  padding: 0;
}
.qr-instructions li {
  margin-bottom: 3px;
}
