/**
 * TaviClean — estilos baseados no mock (veja aqui.txt)
 * Tema claro: azul #1e54b7, menta #22c997, cards brancos vidro
 */

* {
  box-sizing: border-box;
}

:root {
  --color-primary: #1e54b7;
  --color-primary-light: #3b7ddd;
  --color-secondary: #3b7ddd;
  --accent-mint: #22c997;
  --accent-mint-light: #3bddaa;
  --text-dark: #1a1a2e;
  --text-muted: #8896ab;
  --text-soft: #6b7b8d;
  --app-screen-bg: #f8fafc;
  --pill-inactive-bg: #eef2f7;
  --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-dm: 'DM Sans', system-ui, sans-serif;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(160deg, #eef2f7 0%, #e4ecf5 40%, #f0f4f8 100%);
  min-height: 100vh;
  color: var(--text-dark);
}

/* Decoração de fundo (como no mock) */
.app-deco {
  position: absolute;
  pointer-events: none;
  user-select: none;
  opacity: 0.04;
  line-height: 1;
  z-index: 0;
}

.app-deco--1 {
  top: 8%;
  left: 6%;
  font-size: 180px;
  transform: rotate(-15deg);
}

.app-deco--2 {
  bottom: 10%;
  right: 8%;
  font-size: 140px;
  transform: rotate(20deg);
}

.app-deco--3 {
  top: 40%;
  right: 15%;
  font-size: 100px;
  opacity: 0.03;
}

.phone-shell {
  max-width: 400px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

/* Área da app logada — “ecrã” claro */
#view-app {
  background: var(--app-screen-bg);
}

#view-app.modal-open {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

/* Desfocar o ecrã por trás dos modais (view-app + decorações) */
.phone-shell.tc-shell-modal-blur #view-app,
.phone-shell.tc-shell-modal-blur .app-deco {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

#main-scroll {
  background: var(--app-screen-bg);
}

#main-scroll::-webkit-scrollbar {
  width: 0;
}

/* Header estilo mock (barra clara) */
.app-header {
  background: linear-gradient(135deg, #0a1a3f, #12295f) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 2px 14px rgba(2, 8, 23, 0.35);
}

.app-header .header-title {
  color: #f8fafc;
}

.app-header .header-sub {
  color: #cbd5e1;
}

/* Cards — card-glass do mock */
.glass {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 40, 100, 0.06);
}

.glass-dark {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 -2px 20px rgba(0, 40, 100, 0.06);
}

/* Abas em pílula (mock .tab-active) */
.tab-btn {
  padding: 7px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    box-shadow 0.2s;
  background: var(--pill-inactive-bg);
  color: var(--text-soft);
}

.tab-btn.active {
  background: linear-gradient(135deg, #1e54b7, #3b7ddd);
  color: white !important;
  box-shadow: 0 4px 14px rgba(30, 84, 183, 0.3);
  border-bottom: none !important;
}

/* Navegação inferior (mock .bottom-nav) */
.phone-shell .nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted) !important;
  transition: all 0.2s;
  padding: 6px;
  border-radius: 10px;
  background: transparent !important;
}

.phone-shell .nav-btn i {
  width: 20px;
  height: 20px;
}

.phone-shell .nav-btn span {
  font-size: 8px;
  font-weight: 600;
}

.phone-shell .nav-btn.active {
  color: #1e54b7 !important;
  background: rgba(30, 84, 183, 0.08) !important;
}

/* Botão + central (mock .center-action) */
#nav-novo .nav-fab {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1e54b7, #3b7ddd);
  box-shadow: 0 6px 16px rgba(30, 84, 183, 0.35);
}

#nav-novo .nav-fab:hover {
  filter: brightness(1.05);
}

#nav-novo .nav-label {
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
}

/* Auth — cartão branco (mock .auth-container) */
#view-auth {
  justify-content: center;
  padding: 24px 20px;
}

.auth-card {
  background: white;
  border-radius: 20px;
  padding: 30px 24px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1e54b7, #3b7ddd);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(30, 84, 183, 0.25);
  margin: 0 auto 16px;
}

.auth-btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #1e54b7, #3b7ddd);
  color: white;
  transition: filter 0.2s;
}

.auth-btn-primary:hover {
  filter: brightness(1.05);
}

/* Mapa rastreio */
.map-container {
  background: linear-gradient(145deg, #e8f0fe, #dce7f7);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}

.map-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(180, 200, 230, 0.2) 1px, transparent 1px),
    linear-gradient(rgba(180, 200, 230, 0.2) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.map-pin {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  font-size: 0;
}

.map-pin span {
  transform: rotate(45deg);
  font-size: 11px;
  font-weight: 700;
  color: white;
  display: block;
}

/* Toggle checklist — alinhado ao mock */
.toggle-track.on {
  background: var(--accent-mint) !important;
}

.toggle-track.off,
.toggle-track:not(.on) {
  background: #d1d5db !important;
}

.progress-bar-fill {
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, #1e54b7, var(--accent-mint)) !important;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-slide-up {
  animation: fadeSlideUp 0.5s ease forwards;
}

.animate-card {
  animation: fadeSlideUp 0.5s ease forwards;
  opacity: 0;
}

.stagger > * {
  opacity: 0;
  animation: fadeSlideUp 0.45s ease forwards;
}

.stagger > *:nth-child(1) {
  animation-delay: 0.05s;
}
.stagger > *:nth-child(2) {
  animation-delay: 0.1s;
}
.stagger > *:nth-child(3) {
  animation-delay: 0.15s;
}
.stagger > *:nth-child(4) {
  animation-delay: 0.2s;
}
.stagger > *:nth-child(5) {
  animation-delay: 0.25s;
}
.stagger > *:nth-child(6) {
  animation-delay: 0.3s;
}

.scroll-smooth {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.toggle-track:active {
  transform: scale(0.96);
}

.toggle-knob {
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 50px;
  letter-spacing: 0.3px;
}

.hist-tab {
  color: #64748b;
}

.hist-tab.active {
  background: #1e54b7;
  color: #fff;
}

.hist-sep {
  font-size: 12px;
  color: #94a3b8;
  padding: 0 2px;
  user-select: none;
}

.graph-bar {
  border-radius: 6px 6px 0 0;
  transition: height 0.5s ease;
}

#track-map,
#track-map .leaflet-container {
  height: 14rem;
  min-height: 14rem;
  width: 100%;
  border-radius: 0.75rem;
}

@keyframes pulse-ring {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(30, 84, 183, 0.35);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(30, 84, 183, 0);
  }
}

.pulse-status {
  animation: pulse-ring 2s ease-in-out infinite;
}

/* Toasts (mock .toast-notification verde) */
#toast-root > .tc-toast {
  pointer-events: auto;
  background: linear-gradient(135deg, #22c997, #3bddaa);
  color: white;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(34, 201, 151, 0.3);
  animation: slideInToastTop 0.4s ease;
}

@keyframes slideInToastTop {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.balloon-enter {
  animation: fadeSlideFromTop 0.4s ease forwards;
}

.notifications-panel-floating {
  position: fixed;
  top: 74px;
  right: max(12px, calc((100vw - 400px) / 2 + 14px));
  z-index: 160;
}

@keyframes fadeSlideFromTop {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#notification-balloon .glass {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(30, 84, 183, 0.12);
  box-shadow: 0 8px 24px rgba(0, 40, 100, 0.12);
}

/* Modal overlay mock */
#modal-overlay {
  background: rgba(15, 23, 42, 0.28) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#modal-edit,
#modal-appointment,
#modal-service-detail {
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.svc-menu-wrap {
  position: relative;
}

.svc-menu-btn {
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(255, 255, 255, 0.9);
}

.svc-menu {
  position: absolute;
  right: 0;
  top: 34px;
  min-width: 168px;
  max-width: min(220px, 88vw);
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  z-index: 100;
  max-height: 70vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.svc-menu-sub {
  padding: 8px 10px;
  border-top: 1px solid #f1f5f9;
}

.svc-menu-sub-label {
  display: block;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  margin-bottom: 6px;
}

.svc-status-chip {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  margin: 2px 2px 2px 0;
}

.svc-status-chip:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.svc-assign-ms {
  width: 100%;
  font-size: 11px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 4px;
  min-height: 72px;
}

.svc-menu-item {
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.svc-menu-item:hover {
  background: #f8fafc;
}

.svc-menu-item--danger {
  color: #dc2626;
}

.svc-menu-estado-toggle {
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.svc-menu-estado-chips {
  padding-top: 4px;
}

.service-card {
  min-width: 0;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.service-card .status-badge {
  white-space: nowrap;
}

/* Checklist — caixa ao clicar mostra ✕ */
.chk-sq {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 2px solid #cbd5e1;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}
.chk-sq:hover {
  border-color: var(--color-primary, #1e54b7);
}
.chk-sq--on {
  border-color: var(--color-primary, #1e54b7);
  background: var(--color-primary, #1e54b7);
}
.chk-sq-x {
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.hidden-screen {
  display: none !important;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Chat privado equipa — estilo tipo WhatsApp */
.wa-chat-header {
  background: linear-gradient(135deg, #075e54 0%, #128c7e 55%, #25d366 130%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.wa-chat-bg {
  background-color: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23c8c4bc' fill-opacity='0.35'%3E%3Cpath d='M0 0h40v40H0zM40 40h40v40H40z'/%3E%3C/g%3E%3C/svg%3E");
}

.wa-bubble-row {
  width: 100%;
}

.wa-bubble {
  max-width: 88%;
  border-radius: 8px 8px 8px 2px;
  padding: 6px 10px 4px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.wa-bubble-me {
  border-radius: 8px 8px 2px 8px;
  background: #dcf8c6;
  color: #111827;
}

.wa-bubble-them {
  background: #fff;
  color: #111827;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.wa-bubble-text {
  margin: 0;
  word-break: break-word;
}

.wa-bubble-meta {
  margin: 4px 0 0;
  font-size: 10px;
  color: rgba(17, 24, 39, 0.45);
  text-align: right;
}

.wa-bubble-them .wa-bubble-meta {
  text-align: left;
}

.wa-bubble-read {
  margin-left: 2px;
  font-size: 9px;
  opacity: 0.75;
}

/* Lista equipas no drawer — linha contacto */
.drawer-wa-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.drawer-wa-dot--on {
  background: #22c55e;
}

.drawer-wa-dot--off {
  background: #cbd5e1;
}
