/* ============================================================
   CAÇAMBOU — Design System v3.0
   Identidade Visual Oficial | Manual de Identidade Visual v3.0
   ============================================================ */

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
  /* Cores oficiais CAÇAMBOU - Manual de Identidade Visual v3.0 */
  --cacambou-primary:   #0052CC;  /* Azul Principal */
  --cacambou-secondary: #27AE60;  /* Verde Logística */
  --cacambou-white:     #FFFFFF;  /* Branco Limpo */

  /* Aliases para compatibilidade */
  --te-navy:      #0052CC;   /* Azul Principal oficial */
  --te-blue:      #0052CC;   /* Azul Principal oficial */
  --te-green:     #27AE60;   /* Verde Logística */
  --te-cyan:      #0052CC;   /* Azul (consistente) */
  --te-red:       #D41414;   /* Vermelho — "Entulho" */
  --te-yellow:    #F5A800;   /* Amarelo ouro */

  /* Neutros */
  --te-bg:        #F4F6FA;   /* Fundo geral */
  --te-card:      #FFFFFF;   /* Fundo cards */
  --te-text:      #1A1A2E;   /* Texto principal */
  --te-muted:     #6C757D;   /* Texto suave */
  --te-border:    #DEE2EC;   /* Bordas */
  --te-sidebar-w: 240px;

  /* Status de contêineres */
  --te-status-disponivel: #27AE60;  /* Verde */
  --te-status-locado:     #0052CC;  /* Azul */
  --te-status-transito:   #F5A800;  /* Amarelo */
  --te-status-manutencao: #D41414;  /* Vermelho */

  /* Sombras */
  --te-shadow-sm: 0 1px 4px rgba(0,82,204,.08);
  --te-shadow:    0 4px 16px rgba(0,82,204,.12);
}

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* Focus states for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--cacambou-primary);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--cacambou-primary);
  outline-offset: 2px;
}

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background-color: var(--te-bg);
  color: var(--te-text);
  font-size: 1rem;
  line-height: 1.5;
  margin: 0;
}

/* Skip-to-content link for accessibility */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--cacambou-primary);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 101;
  font-weight: 600;
  border-radius: 0 0 4px 0;
}

.skip-to-content:focus {
  top: 0;
  outline: 2px solid white;
  outline-offset: 2px;
}

/* ARIA live region announcements */
[aria-live],
[role="alert"],
[role="status"] {
  position: relative;
}

/* Ensure toast/notification messages are visible and accessible */
.toast,
.alert {
  margin-bottom: 1rem;
}

h1, h2, h3, h4, h5, h6, .te-heading {
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  font-weight: 700;
  color: var(--te-navy);
}

/* ── Sidebar ────────────────────────────────────────────────── */
.te-sidebar {
  width: var(--te-sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--te-navy) 0%, #003a99 100%);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  box-shadow: 4px 0 16px rgba(13,46,110,.18);
  overflow-y: auto;
}

.te-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  min-height: 160px;
}

.te-sidebar-brand img {
  height: 150px;
  width: auto;
  max-width: 95%;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.te-sidebar-brand-text {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.1;
  color: #fff;
}

.te-sidebar-brand-text span {
  color: var(--te-red);
}

.te-sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  list-style: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.te-sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,.88);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: all .18s ease;
  letter-spacing: 0.3px;
}

.te-sidebar-nav .nav-link i {
  font-size: 1.25rem;
  width: 20px;
  text-align: center;
  color: rgba(255,255,255,.9);
  transition: all .18s ease;
}

.te-sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.15);
  transform: translateX(4px);
}

.te-sidebar-nav .nav-link:hover i {
  color: var(--te-green);
  font-size: 1.35rem;
}

.te-sidebar-nav .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.15);
  border-left: 4px solid var(--te-green);
  padding-left: 10px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.2);
}

.te-sidebar-nav .nav-link.active i {
  color: var(--te-green);
  font-size: 1.35rem;
}

/* ── Botão Logout ────────────────────────────────────────────── */
.te-sidebar .nav-link[href="/logout"] {
  margin-top: auto;
  color: #fff;
  font-weight: 700;
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 16px;
  margin-bottom: 0;
  background: linear-gradient(135deg, rgba(212,20,20,.25) 0%, rgba(212,20,20,.15) 100%);
  border: 1.5px solid rgba(212,20,20,.4);
  border-radius: 10px;
  padding: 13px 14px !important;
  margin-top: 16px !important;
  margin-left: 10px;
  margin-right: 10px;
  padding-left: 14px !important;
  padding-right: 14px !important;
  transition: all .25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.te-sidebar .nav-link[href="/logout"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
  transition: left .5s ease;
}

.te-sidebar .nav-link[href="/logout"]:hover::before {
  left: 100%;
}

.te-sidebar .nav-link[href="/logout"] i {
  color: #ff6b6b;
  font-size: 1.35rem;
  transition: all .25s ease;
}

.te-sidebar .nav-link[href="/logout"]:hover {
  background: linear-gradient(135deg, rgba(212,20,20,.4) 0%, rgba(212,20,20,.3) 100%);
  border-color: rgba(212,20,20,.6);
  color: #fff;
  box-shadow: 0 8px 24px rgba(212,20,20,.25), inset 0 1px 0 rgba(255,255,255,.15);
  transform: translateY(-2px) scale(1.02);
}

.te-sidebar .nav-link[href="/logout"]:hover i {
  color: #ff5252;
  font-size: 1.5rem;
  animation: pulse-logout 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.te-sidebar .nav-link[href="/logout"]:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 4px 12px rgba(212,20,20,.2), inset 0 1px 0 rgba(255,255,255,.15);
}

@keyframes pulse-logout {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ── Topbar ─────────────────────────────────────────────────── */
.te-topbar {
  height: 56px;
  background: var(--te-card);
  border-bottom: 1px solid var(--te-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--te-shadow-sm);
  position: sticky;
  top: 0;
  z-index: 99;
}

.te-topbar-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--te-navy);
  margin: 0;
}

.te-topbar-badge {
  background: var(--te-yellow);
  color: var(--te-navy);
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

/* ── Layout principal ───────────────────────────────────────── */
.te-main-wrap {
  margin-left: var(--te-sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.te-content {
  flex: 1;
  padding: 24px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.te-card {
  background: var(--te-card);
  border: 1px solid var(--te-border);
  border-radius: 12px;
  box-shadow: var(--te-shadow-sm);
  padding: 20px;
  transition: box-shadow .2s;
}

.te-card:hover {
  box-shadow: var(--te-shadow);
}

/* Cards do dashboard */
.te-stat-card {
  background: var(--te-card);
  border-radius: 14px;
  padding: 20px 20px 16px;
  border: 1px solid var(--te-border);
  box-shadow: var(--te-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
}

.te-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--te-shadow);
}

.te-stat-card .te-stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.te-stat-card .te-stat-value {
  font-family: 'Montserrat', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--te-navy);
}

.te-stat-card .te-stat-label {
  font-size: .78rem;
  color: var(--te-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Variantes de cor para stat cards */
.te-stat-disponivel .te-stat-icon { background: rgba(34,197,94,.12); color: var(--te-status-disponivel); }
.te-stat-locado     .te-stat-icon { background: rgba(21,101,192,.12); color: var(--te-status-locado); }
.te-stat-transito   .te-stat-icon { background: rgba(245,168,0,.12);  color: var(--te-status-transito); }
.te-stat-pendente   .te-stat-icon { background: rgba(212,20,20,.12);  color: var(--te-status-manutencao); }

/* ── Tabelas ────────────────────────────────────────────────── */
.te-table-wrap {
  background: var(--te-card);
  border-radius: 12px;
  border: 1px solid var(--te-border);
  box-shadow: var(--te-shadow-sm);
  overflow: hidden;
}

.te-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.te-table thead {
  background: var(--te-navy);
}

.te-table thead th {
  color: rgba(255,255,255,.85);
  font-family: 'Montserrat', sans-serif;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 11px 14px;
  border: none;
  white-space: nowrap;
}

.te-table tbody tr {
  border-bottom: 1px solid var(--te-border);
  transition: background .12s;
}

.te-table tbody tr:last-child { border-bottom: none; }

.te-table tbody tr:hover { background: rgba(13,46,110,.03); }

.te-table tbody td {
  padding: 10px 14px;
  color: var(--te-text);
  vertical-align: middle;
}

/* ── Badges de status ───────────────────────────────────────── */
.te-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.te-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.te-badge-disponivel { background: rgba(39,174,96,.12);  color: var(--te-status-disponivel); }
.te-badge-locado     { background: rgba(0,82,204,.12);   color: var(--te-blue); }
.te-badge-transito   { background: rgba(245,168,0,.15);  color: var(--te-status-transito); }
.te-badge-manutencao { background: rgba(212,20,20,.1);   color: var(--te-status-manutencao); }
.te-badge-pendente   { background: rgba(245,168,0,.15);  color: var(--te-status-transito); }
.te-badge-concluido  { background: rgba(39,174,96,.12);  color: var(--te-status-disponivel); }
.te-badge-cancelado  { background: rgba(107,114,128,.12); color: #374151; }

/* ── Botões ─────────────────────────────────────────────────── */
.te-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: .84rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all .16s ease;
}

.te-btn-primary {
  background: var(--te-navy);
  color: #fff;
}
.te-btn-primary:hover { background: #0a235a; color: #fff; transform: translateY(-1px); }

.te-btn-danger {
  background: var(--te-red);
  color: #fff;
}
.te-btn-danger:hover { background: #b30f0f; color: #fff; }

.te-btn-accent {
  background: var(--te-yellow);
  color: var(--te-navy);
}
.te-btn-accent:hover { background: #e09700; }

.te-btn-outline {
  background: transparent;
  color: var(--te-navy);
  border: 1.5px solid var(--te-navy);
}
.te-btn-outline:hover { background: var(--te-navy); color: #fff; }

.te-btn-sm { padding: 5px 12px; font-size: .78rem; }
.te-btn-full { width: 100%; justify-content: center; }

/* ── Formulários ────────────────────────────────────────────── */
.te-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--te-border);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: .88rem;
  color: var(--te-text);
  background: var(--te-card);
  transition: border-color .16s, box-shadow .16s;
  outline: none;
}

.te-input:focus {
  border-color: var(--te-blue);
  box-shadow: 0 0 0 3px rgba(21,101,192,.12);
}

.te-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--te-navy);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Section header ─────────────────────────────────────────── */
.te-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.te-section-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--te-navy);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.te-section-title i {
  color: var(--te-cyan);
}

/* ── Portal do Motorista ────────────────────────────────────── */
.te-driver-wrap {
  min-height: 100vh;
  background: var(--te-navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px;
}

.te-driver-card {
  background: var(--te-card);
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

.te-driver-logo {
  text-align: center;
  margin-bottom: 24px;
}

.te-driver-logo .te-brand-text {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--te-navy);
  line-height: 1;
}

.te-driver-logo .te-brand-text span { color: var(--te-red); }

.te-driver-logo .te-tagline {
  font-size: .75rem;
  color: var(--te-muted);
  margin-top: 2px;
}

.te-task-card {
  background: var(--te-card);
  border: 1px solid var(--te-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--te-shadow-sm);
}

.te-task-card .te-task-type {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: .85rem;
  color: var(--te-navy);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Loading spinner ────────────────────────────────────────── */
.te-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.te-spinner-ring {
  width: 36px;
  height: 36px;
  border: 3px solid var(--te-border);
  border-top-color: var(--te-blue);
  border-radius: 50%;
  animation: te-spin .7s linear infinite;
}

@keyframes te-spin { to { transform: rotate(360deg); } }
@keyframes te-pulse-green {
  0%, 100% { box-shadow: inset 6px 0 0 #16a34a, 0 0 0 0 rgba(22,163,74,.4); }
  50%       { box-shadow: inset 6px 0 0 #16a34a, 0 0 0 6px rgba(22,163,74,.0); }
}
.te-card-acaminho {
  animation: te-pulse-green 2s ease-in-out infinite;
  background: rgba(22,163,74,.10) !important;
  border: 1.5px solid rgba(22,163,74,.35) !important;
}

/* ── Divider com acento ─────────────────────────────────────── */
.te-divider {
  height: 3px;
  background: linear-gradient(90deg, var(--te-navy), var(--te-blue), var(--te-cyan));
  border-radius: 2px;
  margin: 20px 0;
}

/* ── Responsivo ─────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Sidebar vira barra horizontal fixa no topo */
  .te-sidebar {
    width: 100%;
    height: auto;
    min-height: auto;
    overflow-y: visible;
    position: sticky;
    top: 0;
    z-index: 200;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    box-shadow: 0 2px 12px rgba(13,46,110,.3);
  }
  .te-sidebar-brand {
    flex-shrink: 0;
    padding: 8px 14px;
    border-bottom: none;
    border-right: 1px solid rgba(255,255,255,.12);
  }
  /* Nav icon scroll horizontal */
  .te-sidebar-nav {
    flex: 1;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 6px;
    gap: 2px;
    align-items: center;
    margin: 0;
  }
  .te-sidebar-nav::-webkit-scrollbar { display: none; }
  .te-sidebar-nav .nav-link span { display: none; }
  .te-sidebar-nav .nav-link {
    padding: 10px 13px;
    justify-content: center;
    min-width: 44px;
    min-height: 52px;
    flex-shrink: 0;
  }
  .te-sidebar-nav li:not(:has(.nav-link)) { display: none; }
  .te-sidebar-nav li:has([href="/logout"]) { margin-top: 0 !important; padding-top: 0 !important; }
  .te-sidebar .nav-link[href="/logout"] {
    margin-left: 6px !important;
    margin-right: 6px !important;
    padding-left: 13px !important;
    padding-right: 13px !important;
    border-radius: 6px;
  }
  .te-sidebar .nav-link[href="/logout"] i { font-size: 1.25rem; }
  .te-sidebar .nav-link[href="/logout"]:hover i { font-size: 1.35rem; }
  /* Conteúdo abaixo do sidebar */
  .te-main-wrap { margin-left: 0; width: 100%; }
  .te-content { padding: 14px; }
  .te-stat-card .te-stat-value { font-size: 1.5rem; }
  .modal-dialog, .modal-dialog.modal-lg, .modal-dialog.modal-xl { max-width: calc(100vw - 16px); margin: 8px auto; }
  .te-topbar { padding: 0 14px; }
  /* Nome do usuário truncado no topbar */
  .te-topbar-username { max-width: 120px; }
  /* Topbar: previne overflow do conteúdo à direita */
  .te-topbar .ms-auto { min-width: 0; overflow: hidden; }
  /* Inputs e selects com max-width inline tornam-se full-width */
  .te-input[style*="max-width"] { max-width: 100% !important; width: 100%; }
  /* Linha de filtros empilha verticalmente */
  .d-flex.gap-2.mb-3.flex-wrap .te-input { max-width: 100% !important; width: 100%; }
  /* Kanban: garante scroll horizontal correto */
  .te-kanban-wrap { padding-bottom: 12px; }
  /* Ações de tabela: permite quebra de linha */
  .te-table tbody td:last-child { white-space: normal; }
  /* Botão de retirada na tabela: compacto */
  .te-table .te-btn + .te-btn { margin-top: 2px; }
}

@media (max-width: 480px) {
  .te-sidebar-brand { padding: 6px 10px; }
  .te-sidebar-brand-text { font-size: 1rem; }
  .te-sidebar-nav { padding: 0 4px; gap: 0; }
  .te-sidebar-nav .nav-link { padding: 9px 10px; min-width: 40px; font-size: 1.05rem; }
  .te-content { padding: 10px; }
  .te-stat-card { padding: 14px 10px 12px; }
  .te-stat-card .te-stat-value { font-size: 1.2rem; }
  .te-stat-card .te-stat-label { font-size: .68rem; }
  /* Modais full-width */
  .modal-dialog, .modal-dialog.modal-lg, .modal-dialog.modal-xl {
    margin: 6px;
    max-width: calc(100vw - 12px);
  }
  /* Tabelas compactas */
  .te-table { font-size: .8rem; }
  .te-table thead th { padding: 8px 6px; font-size: .64rem; }
  .te-table tbody td { padding: 7px 6px; }
  /* Topbar */
  .te-topbar { padding: 0 10px; gap: 8px; }
  .te-topbar-title { font-size: 1rem; }
  .te-topbar-username { max-width: 80px; }
  /* Seção header: empilha título e botão */
  .te-section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .te-section-header .te-btn { align-self: flex-end; }
  /* Toque mínimo nos botões */
  .te-btn { min-height: 38px; }
  /* Inputs: largura total nos filtros */
  .te-input[style*="max-width"] { max-width: 100% !important; width: 100%; }
  /* Linha de filtros vira coluna */
  .d-flex.gap-2.mb-3.flex-wrap { flex-direction: column; }
  .d-flex.gap-2.mb-3.flex-wrap .te-input { width: 100%; }
  /* Cards de stat: label menor */
  .te-stat-card .te-stat-label { font-size: .65rem; letter-spacing: .02em; }
  /* Botões de ação na tabela: empilham */
  .te-table .te-btn-sm { padding: 4px 8px; font-size: .75rem; }
  /* Form nova locação: campos de endereço full-width */
  .nl-compact .col-md-2, .nl-compact .col-md-3,
  .nl-compact .col-md-4, .nl-compact .col-md-5 { min-width: 0; }
  /* Portal motorista: card mais compacto */
  .te-driver-card { padding: 24px 16px; border-radius: 12px; }
  .te-driver-logo .te-brand-text { font-size: 1.3rem; }
  /* Task cards do motorista: melhor espaçamento */
  .te-task-card { padding: 14px 12px; }
}

@media (max-width: 400px) {
  /* Padding ainda menor */
  .te-content { padding: 6px; }
  /* Fila de Tarefas: botões de ação ocupam largura total */
  .te-acoes-card > .te-btn,
  .te-acoes-card > .te-badge { width: 100%; text-align: center; justify-content: center; }
  .te-acoes-card > div { width: 100%; }
  /* Gap reduzido nos cards */
  .te-card { padding: 10px 8px; }
}

