/* ============================================
   Casa da Obra - Gestão de Entregas
   Main Stylesheet
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Page Transitions ---- */
.page-enter { animation: fadeSlideIn 0.25s ease-out; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Toast Notifications ---- */
.toast {
  pointer-events: all;
  animation: toastIn 0.3s ease-out;
  max-width: 340px;
  min-width: 240px;
}
.toast.removing { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

/* ---- Status Badges ---- */
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ---- Mobile Bottom Nav ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e2e8f0;
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  cursor: pointer;
  transition: color 0.2s;
  font-size: 11px;
  gap: 3px;
  color: #94a3b8;
  border: none;
  background: none;
  flex: 1;
}
.bottom-nav-item.active { color: #f97316; }
.bottom-nav-item i { font-size: 20px; }

/* ---- Cards ---- */
.card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  padding: 16px;
}
.card-hover {
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ---- Buttons ---- */
.btn-primary {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(249,115,22,0.35);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  letter-spacing: 0.02em;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(249,115,22,0.45); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: white;
  color: #f97316;
  border: 2px solid #f97316;
  border-radius: 14px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-secondary:hover { background: #fff7ed; }

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-danger:hover { transform: translateY(-1px); }
.btn-danger:active { transform: scale(0.98); }

.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(34,197,94,0.3);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-success:hover { transform: translateY(-1px); }

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 10px;
}

/* ---- Form Inputs ---- */
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 15px;
  color: #1e293b;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  font-family: 'Inter', sans-serif;
}
.form-input:focus {
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-group { margin-bottom: 16px; }

/* ---- Header ---- */
.app-header {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}
.app-header-title {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
}

/* ---- Map Container ---- */
.map-container {
  width: 100%;
  height: 280px;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 50%, #93c5fd 100%);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.map-placeholder {
  text-align: center;
  color: #3b82f6;
}

/* ---- GPS Pulse ---- */
.gps-pulse {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #22c55e;
  position: relative;
  display: inline-block;
}
.gps-pulse::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(34,197,94,0.3);
  animation: gpsPulse 1.5s infinite;
}
@keyframes gpsPulse {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* ---- Timer ---- */
.timer-display {
  font-size: 42px;
  font-weight: 800;
  color: #1e293b;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}

/* ---- Stat Cards ---- */
.stat-card {
  background: white;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.1;
}
.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* ---- Alert Banner ---- */
.alert-banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #92400e;
}
.alert-banner.danger {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border-color: #ef4444;
  color: #991b1b;
}

/* ---- Sidebar (Admin) ---- */
.admin-sidebar {
  width: 260px;
  min-height: 100vh;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 40;
  overflow-y: auto;
  transition: transform 0.3s;
}
.admin-sidebar.hidden-mobile { transform: translateX(-100%); }
.admin-sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 10px;
  margin: 2px 8px;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
}
.admin-sidebar-item:hover { background: rgba(255,255,255,0.08); color: white; }
.admin-sidebar-item.active { background: rgba(249,115,22,0.2); color: #f97316; }
.admin-content { margin-left: 260px; min-height: 100vh; }

/* ---- Vehicle Card ---- */
.vehicle-card {
  background: white;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-left: 4px solid #e2e8f0;
  transition: all 0.2s;
}
.vehicle-card.active { border-left-color: #22c55e; }
.vehicle-card.maintenance { border-left-color: #f59e0b; }
.vehicle-card.inactive { border-left-color: #ef4444; }

/* ---- Delivery Card ---- */
.delivery-card {
  background: white;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-left: 4px solid;
  transition: all 0.2s;
}
.delivery-card.em_andamento { border-left-color: #3b82f6; }
.delivery-card.finalizada   { border-left-color: #22c55e; }
.delivery-card.pendente     { border-left-color: #f59e0b; }

/* ---- Offline Indicator ---- */
.offline-bar {
  background: #ef4444;
  color: white;
  text-align: center;
  padding: 6px;
  font-size: 12px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 100;
}
.online-bar {
  background: #22c55e;
  color: white;
  text-align: center;
  padding: 6px;
  font-size: 12px;
  font-weight: 600;
  animation: fadeOutBar 3s forwards;
}
@keyframes fadeOutBar {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; height: 0; padding: 0; }
}

/* ---- Login Page ---- */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(160deg, #1e293b 0%, #f97316 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 24px;
  padding: 36px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.center { align-items: center; }
.modal-sheet {
  background: white;
  border-radius: 24px 24px 0 0;
  padding: 24px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}
.modal-sheet.center-modal {
  border-radius: 24px;
  margin: 16px;
  animation: fadeScaleIn 0.25s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes fadeScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---- Progress Bar ---- */
.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f97316, #ea580c);
  border-radius: 3px;
  transition: width 0.5s;
}

/* ---- Tabs ---- */
.tab-bar {
  display: flex;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.tab-item {
  flex: 1;
  padding: 8px 12px;
  border-radius: 9px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
  color: #64748b;
}
.tab-item.active {
  background: white;
  color: #f97316;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ---- Spinner ---- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .admin-content { margin-left: 0; }
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
}

/* ---- Chart Container ---- */
.chart-wrapper {
  position: relative;
  height: 220px;
}

/* ---- Status Step ---- */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.step-line { flex: 1; height: 2px; background: #e2e8f0; }
.step-line.done { background: #22c55e; }

/* ---- Table ---- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid #e2e8f0;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
  color: #334155;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }

/* ---- Logo ---- */
.logo-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 12px rgba(249,115,22,0.35);
}

/* ---- Skeleton Loading ---- */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton 1.4s infinite;
  border-radius: 8px;
}
@keyframes skeleton {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Notif Badge ---- */
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ---- Driver Status Icon ---- */
.driver-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ea580c);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

/* ---- Floating Action Button ---- */
.fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(249,115,22,0.45);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  z-index: 30;
}
.fab:hover { transform: scale(1.08); }
.fab:active { transform: scale(0.95); }

/* ---- Sync indicator ---- */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 20px;
}
.sync-indicator.synced { background: #dcfce7; color: #166534; }
.sync-indicator.pending { background: #fef9c3; color: #854d0e; }
.sync-indicator.offline { background: #fee2e2; color: #991b1b; }

/* ---- Utility ---- */
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.no-select { user-select: none; }
.safe-pb { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
