/* =========================================================
   TransferPro — Design System
   Bootstrap 5 é usado apenas para grid/estrutura. Toda a
   aparência visual (cores, cards, tipografia) é definida aqui.
   ========================================================= */

:root {
  --color-primary: #0D2644;
  --color-primary-dark: #091C33;
  --color-secondary: #1E88E5;
  --color-bg: #F4F6F9;
  --color-surface: #FFFFFF;
  --color-border: #E5E9F0;
  --color-text: #1A2333;
  --color-text-muted: #6B7688;
  --color-success: #1B8A5A;
  --color-success-bg: #E6F6EF;
  --color-warning: #B7791F;
  --color-warning-bg: #FDF3E3;
  --color-danger: #C0392B;
  --color-danger-bg: #FCEAE8;
  --color-info: #1E88E5;
  --color-info-bg: #E8F2FC;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

a { text-decoration: none; }

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 40px; height: 40px; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 260px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1030;
  transition: transform .25s ease, width .25s ease;
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  border-bottom: 1px solid var(--color-border);
}
.app-sidebar__brand img { height: 34px; }
.app-sidebar__brand-name { font-weight: 700; color: var(--color-primary); font-size: 1.05rem; }

.app-sidebar__nav { padding: 12px; overflow-y: auto; flex: 1; }
.nav-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  padding: 14px 12px 6px;
  font-weight: 600;
}
.nav-link-app {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-weight: 500;
  font-size: 0.92rem;
  margin-bottom: 2px;
}
.nav-link-app:hover { background: var(--color-primary); color: #ffffff; }
.nav-link-app.active { background: var(--color-info-bg); color: var(--color-primary); font-weight: 600; }
.nav-link-app .icon { color: inherit; }

.app-main { margin-left: 260px; flex: 1; min-width: 0; display: flex; flex-direction: column; transition: margin-left .25s ease; }

.app-topbar {
  height: 68px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.app-content { padding: 24px; flex: 1; display: flex; flex-direction: column; }

/* Welcome toast (exibido logo após o login) */
.welcome-toast {
  position: fixed;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1060;
  background: var(--color-primary, #0D2644);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  animation: welcome-in .4s ease-out;
}
.welcome-toast.fade-out {
  opacity: 0;
  transform: translateX(-50%) translateY(-8px);
  transition: opacity .45s ease, transform .45s ease;
}
@keyframes welcome-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.app-content.kanban-fullscreen { padding: 16px; overflow: hidden; }

/* Auto-refresh progress bar */
.refresh-bar {
  height: 3px;
  background: transparent;
  position: sticky;
  top: 68px;
  z-index: 1019;
  overflow: hidden;
}
#driverRefreshBar {
  top: 68px; /* motorista layout topbar height */
  position: sticky;
}
.refresh-bar__track {
  height: 100%;
  width: 0%;
  background: var(--color-secondary, #1E88E5);
  border-radius: 0 2px 2px 0;
  transition: width linear;
}
.refresh-bar--refreshing .refresh-bar__track {
  animation: refresh-bar-pulse 0.5s ease-out;
}
@keyframes refresh-bar-pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.4; background: #28a745; }
  100% { opacity: 1; background: var(--color-secondary, #1E88E5); width: 100%; }
}

.sidebar-collapsed .app-sidebar { width: 0; overflow: hidden; }
.sidebar-collapsed .app-sidebar .app-sidebar__brand,
.sidebar-collapsed .app-sidebar .app-sidebar__nav { display: none; }
.sidebar-collapsed .app-main { margin-left: 0; }

@media (max-width: 991px) {
  .app-sidebar { transform: translateX(-100%); width: 260px; }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .app-content { padding: 16px; padding-bottom: 84px; }
  .sidebar-collapsed .app-sidebar { width: 260px; }
}

/* ---------- Cards ---------- */
.card-app {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--color-primary);
}
.stat-card:nth-child(2) { border-left-color: #7C3AED; }
.stat-card:nth-child(3) { border-left-color: #1B8A5A; }
.stat-card:nth-child(4) { border-left-color: #D97706; }
.stat-card:nth-child(5) { border-left-color: #0891B2; }
.stat-card:nth-child(6) { border-left-color: #E11D48; }
.stat-card:nth-child(7) { border-left-color: #059669; }
.stat-card:nth-child(8) { border-left-color: #4338CA; }
.stat-card__icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--color-info-bg);
  color: var(--color-primary);
  flex-shrink: 0;
}
.stat-card__value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-card__label { color: var(--color-text-muted); font-size: 0.82rem; }

/* ---------- Buttons ---------- */
.btn-app {
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  font-size: 0.9rem;
}
.btn-app-primary { background: var(--color-primary); color: #fff; }
.btn-app-primary:hover { background: var(--color-primary-dark); color: #fff; }
.btn-app-outline { background: #fff; color: var(--color-text); border: 1.5px solid #B0B8C4; }
.btn-app-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }

.input-group .form-control { border-right: 0; }
.input-group .btn-app-outline { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group { border-radius: var(--radius-sm); overflow: hidden; }
.btn-app-success { background: var(--color-success); color: #fff; }
.btn-app-danger { background: var(--color-danger); color: #fff; }
.btn-app-lg { padding: 16px 20px; font-size: 1rem; width: 100%; justify-content: center; border-radius: var(--radius-md); }

/* ---------- Badges de status ---------- */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.badge-nova { background: var(--color-info-bg); color: var(--color-info); }
.badge-aguardando_motorista { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-atribuida { background: #EFEAFB; color: #6C3FBF; }
.badge-a_caminho { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-chegou { background: #E3F6FC; color: #0C7FA6; }
.badge-embarcou { background: #E3F6FC; color: #0C7FA6; }
.badge-em_corrida { background: var(--color-info-bg); color: var(--color-primary); }
.badge-finalizada { background: var(--color-success-bg); color: var(--color-success); }
.badge-cancelada { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-ativo { background: var(--color-success-bg); color: var(--color-success); }
.badge-inativo { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-bloqueado { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-disponivel { background: var(--color-success-bg); color: var(--color-success); }
.badge-offline { background: #EEF1F6; color: var(--color-text-muted); }
.badge-ocupado { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-indisponivel { background: var(--color-danger-bg); color: var(--color-danger); }

/* ---------- Kanban ---------- */
.kanban-wrapper {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  flex: 1;
  min-height: 0;
}
.kanban-column {
  min-width: 290px;
  max-width: 290px;
  background: #EEF1F6;
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.kanban-fullscreen .kanban-wrapper {
  height: calc(100vh - 120px);
}
.kanban-fullscreen {
  overflow: hidden;
}
.kanban-column__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 4px 6px 12px;
}
.kanban-column__count {
  background: var(--color-surface);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.76rem;
}
.kanban-cards { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }

.ride-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
.ride-card:active { cursor: grabbing; }
.ride-card.dragging { opacity: 0.4; }
.ride-card--motorista-lock { cursor: default; border-left: 3px solid var(--color-secondary); background: #f5f8ff; }
.ride-card--motorista-lock:active { cursor: default; }
.ride-card__code { font-weight: 700; font-size: 0.82rem; color: var(--color-primary); }
.ride-card__row { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--color-text); margin-top: 6px; }
.ride-card__row .icon { color: var(--color-text-muted); }
.ride-card__value { font-weight: 700; color: var(--color-success); }

.kanban-column.drop-hover { background: #E3EBFA; }

/* ---------- Formulários ---------- */
.form-label-app { font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; }
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1.5px solid #B0B8C4;
  padding: 10px 12px;
  font-size: 0.92rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.15);
}

/* ---------- Login / Splash ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0D2644 0%, #091C33 100%);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
}
.splash-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0D2644 0%, #091C33 100%);
  gap: 18px;
}
.splash-icon {
  width: 84px; height: 84px;
  color: #ffffff;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.75; }
}
.splash-loader {
  width: 160px; height: 4px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}
.splash-loader__bar {
  width: 40%; height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
  animation: loading 1s ease-in-out infinite;
}
@keyframes loading {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ---------- Mobile motorista ---------- */
.driver-mobile { max-width: 480px; margin: 0 auto; padding-bottom: 90px; }
.driver-status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 0.85rem;
}
.driver-status-disponivel { background: var(--color-success-bg); color: var(--color-success); }
.driver-status-ocupado, .driver-status-em_corrida { background: var(--color-warning-bg); color: var(--color-warning); }
.driver-status-offline { background: #EEF1F6; color: var(--color-text-muted); }

.driver-mobile .stat-card:nth-child(1) { border-left-color: #0D2644; }
.driver-mobile .stat-card:nth-child(2) { border-left-color: #1B8A5A; }
.driver-mobile .btn-app-success { background: #1B8A5A; color: #fff; border: none; }
.driver-mobile .btn-app-success:hover { background: #15703F; color: #fff; }
.driver-mobile .btn-app-danger { background: #C0392B; color: #fff; border: none; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 1040;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--color-text-muted); font-size: 0.68rem; font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.bottom-nav a .icon { color: var(--color-text-muted); transition: all 0.2s; }
.bottom-nav a.active { color: var(--color-primary); background: var(--color-info-bg); }
.bottom-nav a.active .icon { color: var(--color-primary); }
.bottom-nav a:nth-child(1).active { color: #0D2644; background: #E8F2FC; }
.bottom-nav a:nth-child(1).active .icon { color: #0D2644; }
.bottom-nav a:nth-child(2).active { color: #1B8A5A; background: #E6F6EF; }
.bottom-nav a:nth-child(2).active .icon { color: #1B8A5A; }
.bottom-nav a:nth-child(3).active { color: #D97706; background: #FDF3E3; }
.bottom-nav a:nth-child(3).active .icon { color: #D97706; }

/* ---------- Timeline (acompanhamento do cliente) ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  display: flex; gap: 14px; padding-bottom: 22px; position: relative;
}
.timeline li:not(:last-child)::before {
  content: '';
  position: absolute; left: 15px; top: 32px; bottom: 0;
  width: 2px; background: var(--color-border);
}
.timeline__dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-border); color: var(--color-text-muted); flex-shrink: 0;
}
.timeline li.done .timeline__dot { background: var(--color-success-bg); color: var(--color-success); }
.timeline li.active .timeline__dot { background: var(--color-primary); color: #fff; }
.timeline__title { font-weight: 700; font-size: 0.9rem; }
.timeline__time { color: var(--color-text-muted); font-size: 0.78rem; }

/* Utilities */
.text-muted-app { color: var(--color-text-muted); }
.shadow-app { box-shadow: var(--shadow-md); }

/* ---------- Success Animation ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.success-checkmark { width: 80px; height: 80px; margin: 0 auto; }
.success-checkmark .icon-circle { height: 80px; width: 80px; border-radius: 50%; position: relative; top: 0; left: 0; background: var(--color-success); }
.success-checkmark .check-icon { width: 80px; height: 80px; position: relative; border-radius: 50%; }
.success-checkmark .check-icon .icon-line { height: 5px; background-color: #fff; display: block; border-radius: 2px; position: absolute; z-index: 10; }
.success-checkmark .check-icon .icon-line.line-tip { top: 46px; left: 14px; width: 25px; transform: rotate(45deg); animation: tip .4s ease-in-out .8s both; }
.success-checkmark .check-icon .icon-line.line-long { top: 38px; right: 8px; width: 47px; transform: rotate(-45deg); animation: long .4s ease-in-out .6s both; }

@keyframes tip { 0% { width: 0; left: 1px; top: 19px; } 54% { width: 0; left: 1px; top: 19px; } 100% { width: 25px; left: 14px; top: 37px; } }
@keyframes long { 0% { width: 0; right: 46px; top: 54px; } 65% { width: 0; right: 46px; top: 54px; } 100% { width: 47px; right: 8px; top: 38px; } }
