@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bs-primary: #6c47ff;
  --bs-primary-rgb: 108, 71, 255;
  --bs-secondary: #8b5cf6;
  --bs-body-font-family: 'Inter', sans-serif;
  --bs-body-bg: #f8f9fb;
  --sidebar-width: 260px;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c4b5fd;
  --sidebar-active: #6c47ff;
  --card-radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --mobile-topbar-h: 52px;
  --mobile-bottom-h: 60px;
}

* { box-sizing: border-box; }
body { font-family: var(--bs-body-font-family); background: var(--bs-body-bg); }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 1040;
  transition: transform .3s ease;
}
.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-name {
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  color: var(--sidebar-text);
  font-size: .72rem;
  font-weight: 400;
}
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.sidebar-nav .nav-item {}
.sidebar-nav .nav-link {
  color: var(--sidebar-text);
  padding: .6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: all .18s;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-nav .nav-link i { font-size: 1rem; opacity: .8; }
.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  color: #fff;
  background: rgba(108, 71, 255, .35);
}
.sidebar-nav .nav-link.active { border-left: 3px solid var(--sidebar-active); }
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  color: var(--sidebar-text);
  font-size: .8rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sidebar-user .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--sidebar-active);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: .8rem;
  flex-shrink: 0;
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1039;
}
.sidebar-overlay.active { display: block; }

/* ── Mobile topbar ── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--mobile-topbar-h);
  background: var(--sidebar-bg);
  padding: 0 1rem;
  align-items: center;
  gap: .75rem;
  z-index: 1030;
}
.mobile-topbar .btn-hamburger {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  padding: .25rem;
  line-height: 1;
  cursor: pointer;
}
.mobile-topbar .mobile-title {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

/* ── Bottom nav (mobile) ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-bottom-h);
  background: #fff;
  border-top: 1px solid #e5e7eb;
  z-index: 1030;
  justify-content: space-around;
  align-items: stretch;
}
.bottom-nav .bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: #9ca3af;
  font-size: .65rem;
  font-weight: 500;
  border: none;
  background: none;
  padding: 0;
  transition: color .15s;
}
.bottom-nav .bn-item i { font-size: 1.25rem; }
.bottom-nav .bn-item.active { color: var(--bs-primary); }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 1.5rem;
  transition: margin .3s ease;
}

/* ── Cards ── */
.card {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid rgba(0,0,0,.07);
  font-weight: 600;
  padding: 1rem 1.25rem .75rem;
}

/* ── KPI Cards ── */
.kpi-card {
  border-radius: var(--card-radius);
  padding: 1.25rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.kpi-card .kpi-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.kpi-card .kpi-label { font-size: .78rem; color: #6b7280; font-weight: 500; }
.kpi-card .kpi-value { font-size: 1.6rem; font-weight: 700; color: #111827; line-height: 1.1; }
.kpi-card .kpi-sub { font-size: .75rem; color: #9ca3af; }

/* ── Tables ── */
.table { font-size: .875rem; }
.table thead th { font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; border-bottom-width: 1px; }
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table-hover tbody tr:hover { background: rgba(108, 71, 255, .04); }

/* ── Badges ── */
.badge { font-weight: 500; letter-spacing: .02em; }

/* ── Forms ── */
.form-label { font-weight: 500; font-size: .85rem; color: #374151; }
.form-control, .form-select {
  border-radius: 8px;
  border-color: #e5e7eb;
  font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px rgba(108, 71, 255, .15);
}

/* ── Buttons ── */
.btn { border-radius: 8px; font-weight: 500; font-size: .875rem; }
.btn-primary {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
}
.btn-primary:hover {
  background: #5b38e8;
  border-color: #5b38e8;
}

/* ── Modals ── */
.modal-content { border: none; border-radius: var(--card-radius); box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal-header { border-bottom-color: #f3f4f6; }
.modal-footer { border-top-color: #f3f4f6; }

/* ── Topbar ── */
.topbar {
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-weight: 600; font-size: 1.1rem; color: #111827; }
.topbar-subtitle { font-size: .8rem; color: #6b7280; }

/* ── Calendar ── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-day {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  min-height: 80px;
  padding: .35rem .4rem;
  cursor: pointer;
  transition: all .15s;
  font-size: .78rem;
}
.calendar-day:hover { border-color: var(--bs-primary); background: rgba(108, 71, 255, .04); }
.calendar-day.today { border-color: var(--bs-primary); background: rgba(108, 71, 255, .06); }
.calendar-day.other-month { opacity: .45; }
.calendar-day .day-num { font-weight: 600; color: #374151; }
.calendar-day .appt-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--bs-primary);
  display: inline-block;
  margin: 1px;
}

/* ── Timeline (dia) ── */
.timeline-row {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: .35rem;
}
.timeline-time { width: 48px; font-size: .75rem; color: #9ca3af; font-weight: 500; flex-shrink: 0; padding-top: .3rem; }
.timeline-slot {
  flex: 1;
  background: #fff;
  border: 1px dashed #e5e7eb;
  border-radius: 6px;
  min-height: 36px;
  padding: .25rem .5rem;
  font-size: .78rem;
  cursor: pointer;
  transition: all .15s;
}
.timeline-slot:hover { border-color: var(--bs-primary); }
.timeline-appt {
  border: none;
  background: rgba(108, 71, 255, .12);
  border-left: 3px solid var(--bs-primary);
  cursor: pointer;
}
.timeline-appt.status-cancelled { background: rgba(239, 68, 68, .1); border-left-color: #ef4444; }
.timeline-appt.status-pending { background: rgba(245, 158, 11, .1); border-left-color: #f59e0b; }

/* ── Booking steps ── */
.step-indicator {
  display: flex;
  align-items: flex-start;
  gap: .2rem;
  margin-bottom: 1.5rem;
}
.step-indicator .step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: .62rem;
  font-weight: 600;
  color: #9ca3af;
  white-space: nowrap;
  flex-shrink: 0;
}
.step-indicator .step::before {
  content: '';
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #e5e7eb;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.step-indicator .step.active { color: var(--bs-primary); }
.step-indicator .step.active::before { background: var(--bs-primary); }
.step-indicator .step.done { color: #10b981; }
.step-indicator .step.done::before { background: #10b981; content: '✓'; color: #fff; font-size: .7rem; }
.step-indicator .step-line { flex: 1; height: 2px; background: #e5e7eb; margin-top: 13px; }
.step-indicator .step-line.done { background: #10b981; }

.service-card {
  border: 2px solid #e5e7eb;
  border-radius: var(--card-radius);
  padding: 1rem;
  cursor: pointer;
  transition: all .18s;
  background: #fff;
}
.service-card:hover, .service-card.selected {
  border-color: var(--bs-primary);
  background: rgba(108, 71, 255, .05);
}
.service-card .service-name { font-weight: 600; color: #111827; }
.service-card .service-meta { font-size: .8rem; color: #6b7280; }
.service-card .service-price { font-size: 1.1rem; font-weight: 700; color: var(--bs-primary); }

.employee-card {
  border: 2px solid #e5e7eb;
  border-radius: var(--card-radius);
  padding: .85rem;
  cursor: pointer;
  transition: all .18s;
  background: #fff;
  text-align: center;
}
.employee-card:hover, .employee-card.selected {
  border-color: var(--bs-primary);
  background: rgba(108, 71, 255, .05);
}
.employee-card .emp-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff; font-weight: 700; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto .5rem;
}

.slot-btn {
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: .4rem .8rem;
  cursor: pointer;
  background: #fff;
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s;
}
.slot-btn:hover, .slot-btn.selected {
  border-color: var(--bs-primary);
  background: var(--bs-primary);
  color: #fff;
}

/* ── Date day buttons (booking step 3) ── */
.date-day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 62px;
  min-height: 72px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  padding: .4rem .3rem;
  transition: all .15s;
  gap: 1px;
}
.date-day-btn:hover {
  border-color: var(--bs-primary);
  background: rgba(108,71,255,.05);
}
.date-day-btn.selected {
  border-color: var(--bs-primary);
  background: var(--bs-primary);
  color: #fff;
}
.date-day-btn .day-name {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  opacity: .7;
}
.date-day-btn .day-num {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.1;
}
.date-day-btn .day-month {
  font-size: .68rem;
  font-weight: 500;
  opacity: .7;
}
.date-day-btn.selected .day-name,
.date-day-btn.selected .day-month { opacity: .85; }

/* ── Status badges ── */
.badge-confirmed { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-attended { background: #dbeafe; color: #1e40af; }
.badge-trial { background: #ede9fe; color: #5b21b6; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-blocked { background: #fee2e2; color: #991b1b; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%);
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
  padding: 2.5rem;
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo .logo-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: var(--bs-primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: #fff; margin-bottom: .75rem;
}
.login-logo h4 { font-weight: 700; color: #111827; margin: 0; }
.login-logo p { font-size: .85rem; color: #6b7280; margin: 0; }

/* ── Loading overlay ── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.spinner-ring {
  width: 40px; height: 40px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--bs-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Landing page ── */
.hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #4c1d95 100%);
  min-height: 100vh;
  display: flex; align-items: center;
  color: #fff;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800; line-height: 1.1; }
.feature-icon {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: rgba(108, 71, 255, .12);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: var(--bs-primary);
  margin-bottom: 1rem;
}

/* ── Flatpickr theme override ── */
.flatpickr-calendar { border-radius: var(--card-radius) !important; box-shadow: var(--shadow-md) !important; border: 1px solid #e5e7eb !important; }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--bs-primary) !important; border-color: var(--bs-primary) !important; }
.flatpickr-day:hover { background: rgba(108, 71, 255, .1) !important; }

/* ═══════════════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE
   ═══════════════════════════════════════════════════ */

@media (max-width: 991.98px) {

  /* Sidebar: hidden off-screen, slides in on toggle */
  .sidebar {
    transform: translateX(-100%);
    top: 0;
    z-index: 1050;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Show mobile topbar and bottom nav */
  .mobile-topbar { display: flex; }
  .bottom-nav { display: flex; }

  /* Main content: push down for topbar, up for bottom nav */
  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: calc(var(--mobile-topbar-h) + 1rem);
    padding-bottom: calc(var(--mobile-bottom-h) + 1rem);
  }

  /* Hide Bootstrap d-lg-none topbar (we use .mobile-topbar instead) */
  .d-lg-none.legacy-mobile-bar { display: none !important; }

  /* Topbar inside sections: stack on small screens */
  .topbar {
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    padding: .6rem 1rem;
  }
  .topbar .btn { font-size: .8rem; padding: .35rem .75rem; }

  /* KPI cards: 2 per row on mobile */
  .kpi-card {
    padding: 1rem .85rem;
    gap: .75rem;
  }
  .kpi-card .kpi-icon { width: 40px; height: 40px; font-size: 1.1rem; }
  .kpi-card .kpi-value { font-size: 1.25rem; }

  /* Tables: horizontal scroll */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table { font-size: .8rem; }
  .table > :not(caption) > * > * { padding: .55rem .6rem; }

  /* Calendar: smaller cells */
  .calendar-grid { gap: 2px; }
  .calendar-day { min-height: 48px; font-size: .7rem; padding: .25rem; }
  .calendar-day .day-num { font-size: .72rem; }

  /* Slot buttons: tighter grid */
  #slots-container { gap: .4rem !important; }
  .slot-btn { padding: .45rem .6rem; font-size: .82rem; }

  /* Service/employee cards: fill width on xs */
  .service-card, .employee-card { padding: .85rem; }

  /* Modals: full-width on mobile */
  .modal-dialog {
    margin: .5rem;
    max-width: calc(100vw - 1rem);
  }
  .modal-dialog.modal-lg,
  .modal-dialog.modal-xl {
    max-width: calc(100vw - 1rem);
  }
  .modal-content { border-radius: 12px; }

  /* Step indicator: smaller dots */
  .step-indicator .step { width: 26px; height: 26px; font-size: .72rem; }
  .step-indicator { gap: .3rem; margin-bottom: 1.25rem; }

  /* Booking confirmation grid: full width cols */
  #step-4 .row .col-6 { flex: 0 0 100%; max-width: 100%; }

  /* Login card: remove extra padding */
  .login-card { padding: 1.75rem 1.25rem; }

  /* Analytics charts: stack */
  #section-analytics .col-md-8,
  #section-analytics .col-md-4,
  #section-analytics .col-md-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Config: stack columns */
  #section-config .col-md-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Calendar filters: stack */
  #section-calendario .col-md-4,
  #section-calendario .col-md-3 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (max-width: 575.98px) {
  /* Booking container: no horizontal padding */
  .booking-container { padding: .75rem .5rem; }

  /* Company header: tighter */
  .company-header { padding: 1.25rem .5rem 1rem; }
  .company-header .company-avatar { width: 58px; height: 58px; font-size: 1.5rem; }

  /* KPI: icons smaller */
  .kpi-card .kpi-icon { width: 36px; height: 36px; font-size: 1rem; border-radius: 8px; }
  .kpi-card .kpi-value { font-size: 1.1rem; }
  .kpi-card .kpi-label { font-size: .72rem; }

  /* Step indicator no mobile: compacto mas com linhas */
  .step-indicator { gap: .1rem; }
  .step-indicator .step { font-size: .58rem; }
  .step-indicator .step::before { width: 22px; height: 22px; }
  .step-indicator .step-line { margin-top: 11px; }

  /* Tables: hide less-important cols on xs */
  .hide-xs { display: none !important; }

  /* Slot buttons: fill row */
  .slot-btn { flex: 1 1 calc(33% - .4rem); text-align: center; }
  #slots-container { display: flex; flex-wrap: wrap; }

  /* Modal footer: stack buttons */
  .modal-footer { flex-direction: column; gap: .5rem; }
  .modal-footer .btn { width: 100%; }

  /* Topbar: smaller title */
  .topbar-title { font-size: .95rem; }
}
