﻿* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.status-online {
  background-color: #dcfce7;
  color: #166534;
}

.status-offline {
  background-color: #fee2e2;
  color: #991b1b;
}

.status-syncing {
  background-color: #fef3c7;
  color: #92400e;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Control buttons (Theme, Lang) */
.btn-icon {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--border-color);
}

.lang-select {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Main Content Area */
.app-content {
  flex: 1;
  padding: 16px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 80px; /* Space for sticky footer */
}

.manager-content {
  max-width: 1400px;
  padding-bottom: 30px;
}

/* Cards */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.client-seq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background-color: var(--brand-primary);
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.client-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.client-address {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.client-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
}

.meta-chip {
  background-color: var(--bg-surface-alt);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

/* Delivery Status Badges */
.badge-status {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.badge-pendente {
  background-color: var(--status-pending-bg);
  color: var(--status-pending-text);
}

.badge-entregue {
  background-color: var(--status-delivered-bg);
  color: var(--status-delivered-text);
  border: 1px solid var(--status-delivered-border);
}

.badge-nao-entregue {
  background-color: var(--status-failed-bg);
  color: var(--status-failed-text);
  border: 1px solid var(--status-failed-border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  min-height: 44px;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
}

.btn-success {
  background-color: #16a34a;
  color: white;
}

.btn-success:hover {
  background-color: #15803d;
}

.btn-danger {
  background-color: #dc2626;
  color: white;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-secondary {
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-block {
  width: 100%;
}

/* Footer Fixo */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-footer);
  border-top: 1px solid var(--border-color);
  box-shadow: var(--shadow-footer);
  display: flex;
  justify-content: space-around;
  padding: 8px 12px;
  z-index: 1000;
  height: 64px;
}

.footer-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}

.footer-btn.active, .footer-btn:hover {
  color: var(--brand-primary);
}

.footer-btn svg {
  width: 20px;
  height: 20px;
}

/* Modals - High Z-Index to stay ABOVE Leaflet map (Leaflet uses 400-1000) */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 99999 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex !important;
}

.modal-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 100000 !important;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
}

/* Dashboard Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--brand-primary);
  margin-top: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
}

/* Map Container */
#map {
  width: 100%;
  height: 400px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
  position: relative;
  z-index: 1 !important;
}

/* Table */
.data-table-wrapper {
  overflow-x: auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background-color: var(--bg-surface-alt);
  padding: 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}
