/* ==========================================================================
   DELIVERY PRO - EASY INTELLIGENCE BASE MODULES & ADVANCED EXTENSIONS
   Includes: Dynamic Tables, InfoLabels, AddressPickers, Wizards, Audit Views,
   Payment Reconciliation, Live Chat, Incident Reassignment, Driver Documents,
   and Municipality Courier Integration.
   ========================================================================== */

/* InfoLabel Component */
.info-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: help;
  position: relative;
}

.info-label .info-icon {
  color: var(--primary);
  font-size: 0.85rem;
  opacity: 0.8;
  transition: opacity var(--transition-fast);
}

.info-label:hover .info-icon {
  opacity: 1;
}

.info-tooltip {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: normal;
  width: max-content;
  max-width: 260px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 1000;
}

.info-label:hover .info-tooltip {
  opacity: 1;
}

/* Forms & Inputs (Semantic Standards) */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--text-subtle);
  pointer-events: none;
  font-size: 0.95rem;
}

.form-control {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  color: var(--input-text);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  outline: none;
}

.input-with-icon .form-control {
  padding-left: 2.5rem;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control.uppercase {
  text-transform: uppercase;
}

.form-control.has-error,
.form-control.is-invalid {
  border-color: var(--easy-red, #ef4444) !important;
  background: rgba(239, 68, 68, 0.08) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
  animation: shakeInput 0.3s ease-in-out;
}

@keyframes shakeInput {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.field-error-msg,
.invalid-feedback {
  font-size: 0.74rem;
  color: var(--easy-red, #ef4444);
  font-weight: 600;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  animation: fadeInError 0.2s ease-out;
}

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

/* Dynamic Data Tables */
.data-table-wrapper {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.data-table-toolbar {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.table-search-box {
  position: relative;
  min-width: 260px;
}

.table-search-box input {
  padding-left: 2.25rem;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.custom-table th {
  background: var(--easy-navy-light);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  font-weight: 700;
  border-bottom: 2px solid var(--border-subtle);
  letter-spacing: 0.3px;
}

.custom-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.custom-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.custom-table td.col-numeric,
.custom-table th.col-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.table-pagination {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* LIVE CHAT SYSTEM (Cliente 💬 Repartidor 💬 Despacho) */
.chat-window {
  display: flex;
  flex-direction: column;
  height: 480px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.chat-header {
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-messages-container {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
}

.chat-bubble {
  max-width: 78%;
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.4;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chat-bubble.sent {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  border-bottom-right-radius: 2px;
}

.chat-bubble.received {
  align-self: flex-start;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

.chat-meta {
  font-size: 0.68rem;
  opacity: 0.75;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-input-bar {
  padding: 0.75rem 1rem;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 0.5rem;
}

/* INCIDENT & EMERGENCY REASSIGNMENT */
.incident-card {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.incident-alert-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fda4af;
  font-weight: 700;
  font-size: 0.9rem;
}

/* MUNICIPALITY / GOVERNMENT COURIER BADGE & PORTAL */
.badge-gov {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(99, 102, 241, 0.2));
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.4);
  font-weight: 700;
}

.gov-portal-card {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.8), rgba(30, 41, 59, 0.6));
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 8px 25px rgba(6, 182, 212, 0.15);
}

.token-code-box {
  background: rgba(0, 0, 0, 0.5);
  border: 1px dashed var(--accent-cyan);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.85rem;
  color: #a5f3fc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* DRIVER DOCUMENTS VERIFICATION MODAL */
.doc-preview-item {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

.doc-status-badge {
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
}

.doc-status-badge.verified {
  background: var(--accent-emerald-light);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.doc-status-badge.pending {
  background: var(--accent-amber-light);
  color: #facc15;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ==========================================================================
   SERVER HEALTH & TELEMETRY DASHBOARD
   ========================================================================== */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.health-metric-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.health-metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
}

.health-metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.health-metric-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.health-metric-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* SERVER LOGS STREAMING TERMINAL CONSOLE */
.server-logs-wrapper {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.server-logs-toolbar {
  padding: 0.75rem 1.25rem;
  background: var(--easy-navy-light);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.server-logs-console {
  background: #060814;
  color: #e2e8f0;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  padding: 1rem;
  height: 340px;
  overflow-y: auto;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

[data-theme="light"] .server-logs-console {
  background: #0f172a;
  color: #f1f5f9;
}

.log-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.log-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-time {
  color: #64748b;
  font-size: 0.72rem;
  white-space: nowrap;
}

.log-badge {
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
}

.log-badge.info { background: rgba(0, 169, 255, 0.2); color: #38bdf8; }
.log-badge.success { background: rgba(23, 151, 38, 0.2); color: #4ade80; }
.log-badge.warn { background: rgba(212, 139, 64, 0.2); color: #fbbf24; }
.log-badge.error { background: rgba(209, 23, 20, 0.2); color: #f87171; }
.log-badge.ws { background: rgba(147, 51, 234, 0.2); color: #c084fc; }

.log-msg {
  flex: 1;
  word-break: break-word;
}

/* CATEGORY & USER BADGES */
.category-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: all var(--transition-fast);
}

.category-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

.category-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--easy-blue-light);
  color: var(--easy-blue);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
}
