/* Salgo Business Dashboard — custom styles */

/* ─── Base resets & variables ──────────────────────────────────────────── */
:root {
  --color-sidebar-bg: #1e293b;
  --color-sidebar-text: #94a3b8;
  --color-sidebar-active-text: #ffffff;
  --color-sidebar-active-bg: #334155;
  --color-accent: #3b82f6;
  --color-accent-hover: #2563eb;
  --color-surface: #ffffff;
  --color-bg: #f1f5f9;
  --color-border: #e2e8f0;
  --color-text-primary: #0f172a;
  --color-text-secondary: #64748b;
  --transition-speed: 0.25s;
  --sidebar-width: 15rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  transition: transform var(--transition-speed) cubic-bezier(.4,0,.2,1);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color var(--transition-speed), color var(--transition-speed);
  cursor: pointer;
  user-select: none;
}

.sidebar-nav-item:hover {
  background-color: var(--color-sidebar-active-bg);
  color: var(--color-sidebar-active-text);
}

.sidebar-nav-item.is-active {
  /* overridden by dashboard.html inline styles for gradient */
  color: var(--color-sidebar-active-text);
}

.sidebar-nav-item svg {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
}

/* ─── Mobile sidebar overlay ────────────────────────────────────────────── */
#sidebar-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 39;
}

/* ─── KPI cards ─────────────────────────────────────────────────────────── */
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,.07);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: box-shadow var(--transition-speed);
}

.kpi-card:hover { box-shadow: 0 4px 12px 0 rgba(0,0,0,.10); }

.kpi-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-card__value {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.kpi-card__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}

/* ─── Status badges ─────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  display: block;
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-badge-active  { background: #dcfce7; color: #15803d; }
.status-badge-active::before  { background: #16a34a; }
.status-badge-inactive { background: #fee2e2; color: #b91c1c; }
.status-badge-inactive::before { background: #dc2626; }
.status-badge-pending  { background: #fef9c3; color: #a16207; }
.status-badge-pending::before  { background: #ca8a04; }

/* ─── Drawer overlay & panel ────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,.45);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) ease;
}

.drawer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 26rem;
  max-width: 100vw;
  background: var(--color-surface);
  z-index: 50;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
  transform: translateX(100%);
  transition: transform var(--transition-speed) cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-panel.is-open { transform: translateX(0); }

.drawer-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
  flex-shrink: 0;
}

.drawer-panel__body {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer-panel__footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-shrink: 0;
  background: var(--color-surface);
}

/* ─── Form elements ─────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 0.375rem;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  background: var(--color-surface);
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
  outline: none;
  /* iOS fix */
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.form-input::placeholder { color: #94a3b8; }

/* ─── Upload zone ───────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  transition: border-color var(--transition-speed), background var(--transition-speed);
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--color-accent);
  background: #eff6ff;
}

.upload-zone__note {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5625rem 1.125rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background-color var(--transition-speed), opacity var(--transition-speed), transform .1s;
  user-select: none;
  text-decoration: none;
  /* mobile tap highlight */
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); color: var(--color-text-primary); }

.btn-ghost { background: transparent; color: var(--color-text-secondary); padding: 0.375rem 0.625rem; }
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text-primary); }

.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }

/* ─── Data table ────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
  background: #f8fafc;
  white-space: nowrap;
}

.data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fafc; }

/* Mobile card view for table rows */
.spot-card {
  display: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

/* ─── Avatar circle ─────────────────────────────────────────────────────── */
.avatar-circle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-circle img,
.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* ─── Placeholder boxes ─────────────────────────────────────────────────── */
.placeholder-box {
  background: var(--color-bg);
  border: 2px dashed var(--color-border);
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

/* ─── Login page ────────────────────────────────────────────────────────── */
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 22rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.login-logo {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-accent);
  letter-spacing: -0.03em;
}

.login-badge {
  display: inline-block;
  background: #eff6ff;
  color: var(--color-accent);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid #bfdbfe;
  margin-top: 0.25rem;
}

/* ─── Stat card (detail page) ───────────────────────────────────────────── */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  text-align: center;
}

.stat-card__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.stat-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

/* ─── Scrollbar polish ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET  ≤ 1024px
═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE  ≤ 768px
═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Drawer full width */
  .drawer-panel { width: 100vw; }

  /* Sidebar becomes a slide-out overlay */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 40;
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }

  #sidebar.is-open {
    transform: translateX(0);
  }

  #sidebar-mobile-overlay.is-open {
    display: block;
  }

  /* Main area takes full width */
  body > .flex { flex-direction: column; }

  /* KPI grid 2 columns on mobile */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Table → card view on mobile */
  .data-table thead { display: none; }

  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tbody tr {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 0.75rem;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.25rem 0.5rem;
    align-items: start;
  }

  .data-table tbody tr:hover td { background: transparent; }

  .data-table td {
    padding: 0;
    border: none;
    font-size: 0.875rem;
  }

  /* First td = address (full width, bold) */
  .data-table td:first-child {
    grid-column: 1 / 2;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--color-text-primary);
  }

  /* Status badge = top right */
  .data-table td:nth-child(2) {
    grid-column: 2 / 3;
    grid-row: 1;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
  }

  /* Capacity + Price = small labels */
  .data-table td:nth-child(3),
  .data-table td:nth-child(4) {
    grid-column: 1 / 2;
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
  }

  .data-table td:nth-child(3)::before { content: 'Vagas: '; font-weight: 600; color: var(--color-text-primary); }
  .data-table td:nth-child(4)::before { content: 'Preço: '; font-weight: 600; color: var(--color-text-primary); }

  /* Actions = full width row at bottom */
  .data-table td:nth-child(5) {
    grid-column: 1 / 3;
    margin-top: 0.625rem;
    padding-top: 0.625rem;
    border-top: 1px solid var(--color-border);
  }

  .data-table td:nth-child(5) .flex {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Main content padding */
  main.flex-1 { padding: 1rem !important; }

  /* KPI value smaller */
  .kpi-card__value { font-size: 1.375rem; }
  .kpi-card { padding: 1rem; }

  /* Top bar */
  header .hidden { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE  ≤ 480px
═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .kpi-card__value { font-size: 1.25rem; }

  .login-card {
    padding: 2rem 1.25rem;
    border-radius: 0.75rem;
    margin: 1rem;
    max-width: none;
  }
}
