:root {
  --primary: #1e3a5f;
  --primary-dark: #152d4a;
  --primary-light: #2d5a8f;
  --sidebar-width: 260px;
  --header-height: 60px;
}

[data-bs-theme="dark"] {
  --bs-body-bg: #0f1a2e;
  --bs-body-color: #e2e8f0;
  --bs-border-color: #1e293b;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: #f1f5f9;
  overflow-x: hidden;
}

[data-bs-theme="dark"] body {
  background-color: #0a0f1a;
}

/* Login */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1f33 0%, #1e3a5f 50%, #152d4a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: white;
  border-radius: 1.5rem;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  max-width: 420px;
  width: 100%;
}

.login-logo {
  width: 72px;
  height: 72px;
  background: rgba(30,58,95,0.1);
  border-radius: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1e3a5f 0%, #152d4a 100%);
  z-index: 1040;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand-icon {
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,0.15);
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.sidebar-brand-text {
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-nav {
  padding: 0.75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s;
  margin-bottom: 0.15rem;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.sidebar-link.active {
  background: rgba(255,255,255,0.18);
  color: white;
  font-weight: 600;
}

.sidebar-link i {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
}

.sidebar-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  border-radius: 999px;
  text-align: center;
  padding: 0 6px;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  padding: 0.5rem;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

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

/* Top header for mobile */
.top-header {
  display: none;
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

[data-bs-theme="dark"] .top-header {
  background: #0f1a2e;
  border-bottom-color: #1e293b;
  color: #e2e8f0;
}

/* Kanban Board */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: calc(100vh - 280px);
  align-items: flex-start;
}

.kanban-column {
  flex: 0 0 300px;
  min-width: 300px;
  background: #f8fafc;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
}

[data-bs-theme="dark"] .kanban-column {
  background: #1e293b;
  border-color: #334155;
}

.kanban-column-header {
  padding: 0.85rem 1rem;
  border-radius: 1rem 1rem 0 0;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 2;
}

.kanban-column-body {
  padding: 0.6rem;
  overflow-y: auto;
  flex: 1;
}

.kanban-card {
  background: white;
  border-radius: 0.75rem;
  padding: 0.85rem;
  margin-bottom: 0.6rem;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #94a3b8;
  cursor: grab;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: relative;
}

.kanban-card:hover {
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.12), 0 4px 10px -6px rgba(0,0,0,0.08);
  transform: translateY(-3px) rotate(0.5deg);
  border-left-width: 6px;
  z-index: 10;
}

.kanban-card:active {
  cursor: grabbing;
  transform: translateY(-1px) rotate(1.5deg) scale(0.99);
  box-shadow: 0 15px 35px -5px rgba(0,0,0,0.18);
}

.kanban-card[data-status="agendado"] { border-left-color: #f59e0b; }
.kanban-card[data-status="em_curso"] { border-left-color: #3b82f6; }
.kanban-card[data-status="concluido"] { border-left-color: #10b981; }
.kanban-card[data-status="cancelado"] { border-left-color: #ef4444; }
.kanban-card-paused { border-left-color: #f59e0b !important; }
.kanban-card-paused .live-timer { color: #f59e0b; }

[data-bs-theme="dark"] .kanban-card {
  background: #1a2332;
  border-color: #334155;
}

[data-bs-theme="dark"] .kanban-card:hover {
  border-color: #475569;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5);
}

.kanban-card-client {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e293b;
  margin-bottom: 0.3rem;
}

[data-bs-theme="dark"] .kanban-card-client {
  color: #e2e8f0;
}

.kanban-card-location {
  font-size: 0.8rem;
  color: #64748b;
}

.kanban-card-meta {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===== Linhas coloridas da folha de ponto e da grelha de faturacao =====
   As classes .table-primary/.table-danger/... do Bootstrap tem cores claras
   FIXAS: em tema escuro ficavam a brilhar no meio da tabela. As tabelas pintam
   pela variavel --bs-table-bg, e nao pelo background do <tr>, por isso e essa
   que tem de mudar. */
.linha-folga   { --bs-table-bg: #dbeafe; }
.linha-falta   { --bs-table-bg: #fee2e2; }
.linha-ferias  { --bs-table-bg: #ede4fb; }
.linha-baixa   { --bs-table-bg: #fdf0d5; }
.linha-feriado { --bs-table-bg: #dcfce7; }
.linha-fds     { --bs-table-bg: #eef2f7; }
.linha-precos  { --bs-table-bg: #eef2f7; }
.linha-total   { --bs-table-bg: #1e3a5f; color: #fff; }

[data-bs-theme="dark"] .linha-folga   { --bs-table-bg: #1c3557; }
[data-bs-theme="dark"] .linha-falta   { --bs-table-bg: #4a1d24; }
[data-bs-theme="dark"] .linha-ferias  { --bs-table-bg: #33264f; }
[data-bs-theme="dark"] .linha-baixa   { --bs-table-bg: #45360f; }
[data-bs-theme="dark"] .linha-feriado { --bs-table-bg: #14402a; }
[data-bs-theme="dark"] .linha-fds     { --bs-table-bg: #16202f; }
[data-bs-theme="dark"] .linha-precos  { --bs-table-bg: #16202f; }
[data-bs-theme="dark"] .linha-total   { --bs-table-bg: #0b1b33; color: #e2e8f0; }

/* Etiqueta dos minutos que fica POR CIMA da barra de progresso. Tem de se ler
   tanto sobre a barra colorida como sobre a parte vazia, por isso leva um halo
   da cor do fundo. Estava com #111 e halo branco fixos no HTML, o que em tema
   escuro dava texto quase preto com auréola branca. */
.progresso-etiqueta {
  color: #111;
  text-shadow: 0 0 3px rgba(255,255,255,.9), 0 0 3px rgba(255,255,255,.9);
}

[data-bs-theme="dark"] .progresso-etiqueta {
  color: #f8fafc;
  text-shadow: 0 0 3px rgba(0,0,0,.85), 0 0 3px rgba(0,0,0,.85);
}

/* Timer — o contador deixou de ser o elemento principal: quem indica o estado
   agora e a barra de progresso, por isso o numero fica pequeno por cima dela. */
.timer-display {
  font-size: 1.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
}

@media (max-width: 767px) {
  .timer-display {
    font-size: 1.5rem;
  }
}

/* Service card list (mobile chief) */
.service-card {
  border-radius: 1rem;
  transition: all 0.2s;
}

.service-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .top-header {
    display: flex;
  }

  .kanban-column {
    flex: 0 0 280px;
    min-width: 280px;
  }
}

/* Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1035;
}

.sidebar-backdrop.show {
  display: block;
}

/* Stats */
.stat-card {
  border-radius: 1rem;
  border: none;
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
}

/* Spinner */
.spinner-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9990;
}

[data-bs-theme="dark"] .spinner-overlay {
  background: rgba(15,26,46,0.7);
}

.kanban-card-late {
  border-left-color: #ef4444 !important;
  animation: latePulse 2s ease-in-out infinite;
}

@keyframes latePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.kanban-card-live {
  border-left-color: #3b82f6 !important;
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
}

/* Print / Export */
@media print {
  .sidebar, .top-header, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
}

/* Calendar (mobile-style) */
.cal-day {
  position: relative;
  min-height: 44px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background 0.15s;
  text-align: center;
}
.cal-day-num {
  font-weight: 600;
  font-size: 0.92rem;
  color: #334155;
}
.cal-dots {
  display: flex;
  gap: 3px;
  margin-top: 3px;
  min-height: 6px;
}
/* Cada ponto = um servico, com a cor do estado. Eram todos verdes, o que dava a
   entender que dias ainda por acontecer ja estavam feitos. */
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
  flex: 0 0 auto;
}

.cal-dot-agendado  { background: #94a3b8; }
.cal-dot-curso     { background: #3b82f6; }
.cal-dot-feito     { background: #22c55e; }
.cal-dot-cancelado { background: #ef4444; opacity: .55; }

/* "+2" quando ha mais servicos do que os pontos que cabem */
.cal-mais {
  font-size: 8px;
  line-height: 6px;
  font-weight: 700;
  color: var(--bs-secondary-color, #64748b);
  margin-left: 1px;
}
.cal-day-has { cursor: pointer; }
.cal-day-has:hover { background: #ecfdf5; }
[data-bs-theme="dark"] .cal-day-has:hover { background: #16323f; }

/* O dia escolhido fica azul da marca (e nao verde, que agora quer dizer
   "concluido" nos pontos). Os pontos mantem a cor do estado, com um anel
   branco a garantir que se leem sobre o fundo cheio. */
.cal-day-active {
  background: var(--primary) !important;
}
.cal-day-active .cal-day-num { color: #fff; }
.cal-day-active .cal-dot { box-shadow: 0 0 0 1px rgba(255,255,255,.85); }
.cal-day-active .cal-mais { color: #fff; }

/* Mobile experience */
@media (max-width: 576px) {
  .metric-card { border-radius: 14px; }
  .cal-day { min-height: 48px; border-radius: 12px; }
  .cal-day-num { font-size: 0.9rem; }
}

/* Polimento: cards modernos, transições suaves, toques maiores */
.card {
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.card.service-card:hover,
.metric-card:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }
.metric-card { border-radius: 16px; }

.badge-subtle, .bg-success-subtle, .bg-warning-subtle, .bg-danger-subtle, .bg-info-subtle, .bg-primary-subtle {
  border-radius: 999px;
  font-weight: 600;
}

/* Botões maiores no telemóvel (facilita toque) */
@media (max-width: 576px) {
  .btn-lg, .btn { padding-top: 0.65rem; padding-bottom: 0.65rem; }
  .fs-5 { font-size: 1.05rem; }
}

/* Lista de serviços única (substituiu o kanban) */

/* Linhas de total / cabeçalhos subtis que respeitam o tema claro/escuro */
.row-subtle { background: #f8f9fa; }
[data-bs-theme="dark"] .row-subtle { background: #1e293b; }

/* Titulo de grupo no menu lateral. Separa o que se usa todos os dias do que
   se configura uma vez — oito entradas seguidas nao diziam por onde comecar. */
.sidebar-grupo {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 0.75rem 1.25rem 0.35rem;
  margin-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
