/* ============================================
   RESUELVELO - Design System
   ============================================ */

:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #DBEAFE;
  --secondary: #F59E0B;
  --secondary-dark: #D97706;
  --success: #10B981;
  --success-light: #D1FAE5;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --info: #06B6D4;
  --info-light: #CFFAFE;

  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #1E293B;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-light: #94A3B8;
  --border: #E2E8F0;
  --border-focus: #2563EB;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  --transition: all 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-width: 260px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ---- Typography ---- */
h1 { font-size: 1.875rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.125rem; font-weight: 500; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-secondary { color: var(--text-secondary); }
.text-light { color: var(--text-light); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

/* ---- Layout ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover:not(:disabled) { background: var(--secondary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #DC2626; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius); }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-card);
  transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-light); }
.form-hint { font-size: 0.75rem; color: var(--text-light); margin-top: 0.25rem; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: #065F46; }
.badge-danger { background: var(--danger-light); color: #991B1B; }
.badge-warning { background: var(--warning-light); color: #92400E; }
.badge-info { background: var(--info-light); color: #155E75; }
.badge-gray { background: #F1F5F9; color: var(--text-secondary); }

/* ---- Status Badges ---- */
.status-pending { background: var(--warning-light); color: #92400E; }
.status-published { background: var(--info-light); color: #155E75; }
.status-assigned { background: var(--primary-light); color: var(--primary); }
.status-en_route { background: #EDE9FE; color: #5B21B6; }
.status-in_progress { background: #FEF3C7; color: #92400E; }
.status-paused { background: #F1F5F9; color: var(--text-secondary); }
.status-completed { background: var(--success-light); color: #065F46; }
.status-cancelled { background: var(--danger-light); color: #991B1B; }
.status-reviewed { background: #D1FAE5; color: #065F46; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead { background: var(--bg); }
th { padding: 0.75rem 1rem; text-align: left; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--border); }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
tr:hover { background: #F8FAFC; }

/* ---- App Layout ---- */
.app-layout { display: flex; min-height: 100vh; }
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-topbar {
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-content { flex: 1; padding: 1.5rem; }

/* Sidebar elements */
.sidebar-brand {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand h2 { color: white; font-size: 1.125rem; }
.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}
.sidebar-nav { flex: 1; padding: 0.75rem; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  color: #CBD5E1;
  font-size: 0.875rem;
  transition: var(--transition);
  text-decoration: none;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,0.1);
  color: white;
}
.sidebar-nav a.active { background: var(--primary); }
.sidebar-nav .nav-section {
  padding: 0.5rem 0.875rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748B;
  margin-top: 1rem;
}
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: #CBD5E1;
  font-size: 0.875rem;
}
.sidebar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: white;
}

/* ---- Mobile sidebar toggle ---- */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
  padding: 0.25rem;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ---- KPI Cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.kpi-card .kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--text); }
.kpi-card .kpi-label { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.25rem; }
.kpi-card .kpi-icon { font-size: 1.5rem; }

/* ---- Notifications ---- */
.notif-bell { position: relative; cursor: pointer; }
.notif-bell .notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.notif-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 360px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}
.notif-dropdown.show { display: block; }
.notif-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }
.notif-item .notif-title { font-size: 0.8125rem; font-weight: 500; }
.notif-item .notif-message { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.125rem; }
.notif-item .notif-time { font-size: 0.6875rem; color: var(--text-light); margin-top: 0.25rem; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s ease;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
}
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  color: white;
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: #1E293B; }
.toast-info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ---- Photo gallery ---- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.5rem; }
.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .photo-phase {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 0.625rem;
  text-transform: uppercase;
  padding: 0.25rem;
  text-align: center;
}

/* ---- Stars ---- */
.stars { display: flex; gap: 0.125rem; }
.star { cursor: pointer; font-size: 1.5rem; color: #CBD5E1; transition: color 0.15s; }
.star.active { color: #F59E0B; }
.star:hover { color: #F59E0B; }

/* ---- Loader ---- */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ---- Pulse dot (for live/online) ---- */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---- Job alert animation (Uber style) ---- */
.job-alert {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--primary);
  padding: 1.25rem;
  width: 90%;
  max-width: 400px;
  z-index: 300;
  animation: bounceUp 0.4s ease;
}
@keyframes bounceUp {
  0% { transform: translateX(-50%) translateY(100%); }
  60% { transform: translateX(-50%) translateY(-10px); }
  100% { transform: translateX(-50%) translateY(0); }
}
.job-alert-timer {
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
  margin-top: 0.75rem;
  animation: shrink 30s linear forwards;
}
@keyframes shrink { to { width: 0; } }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .sidebar-overlay.show { display: block; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .notif-dropdown { width: 300px; right: -1rem; }
  .modal { max-width: 100%; }
  .app-content { padding: 1rem; }
  h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .btn { padding: 0.5rem 1rem; font-size: 0.8125rem; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ---- Map ---- */
.map-container { height: 300px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.map-container.map-lg { height: 500px; }
.map-container.map-full { height: calc(100vh - 200px); }
