/* =====================================================
   RB Fleet — Design System Global
   ===================================================== */

/* ─── TOKENS ───────────────────────────────────────── */
:root {
  --brand:        #1d4ed8;
  --brand-dark:   #1e3a8a;
  --brand-light:  #eff6ff;
  --surface:      #ffffff;
  --surface-2:    #f9fafb;
  --surface-3:    #f3f4f6;
  --border:       #e5e7eb;
  --border-light: #f1f5f9;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted:   #9ca3af;
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);
}

/* ─── TOAST ─────────────────────────────────────────── */
#toast-container > div {
  animation: toastSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#toast-container > div.removing {
  animation: toastSlideOut 0.2s ease-in forwards;
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(2rem) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0) scale(1); max-height: 100px; }
  to   { opacity: 0; transform: translateX(2rem) scale(0.9); max-height: 0; }
}

/* ─── PAGE HEADER ───────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

/* ─── DATA TABLE ─────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table thead tr {
  background-color: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.data-table thead th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.1s;
}
.data-table tbody tr:hover { background-color: var(--surface-2); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody td {
  padding: 0.75rem 1rem;
  color: #374151;
  vertical-align: middle;
}

/* ─── KPI CARDS ──────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.125rem;
  transition: box-shadow 0.2s, transform 0.15s;
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ─── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.25;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Variantes */
.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 1px 3px rgba(29,78,216,0.2);
}
.btn-primary:hover:not(:disabled) {
  background: #1e40af;
  box-shadow: 0 4px 12px rgba(29,78,216,0.3);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
  background: var(--surface);
  color: #374151;
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: #9ca3af;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-warning {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}
.btn-warning:hover:not(:disabled) { background: #ffedd5; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text-primary);
}

/* Tamaños */
.btn-sm  { padding: 0.375rem 0.625rem; font-size: 0.8125rem; border-radius: 7px; }
.btn-xs  { padding: 0.25rem 0.5rem;   font-size: 0.75rem;   border-radius: 6px; }
.btn-lg  { padding: 0.625rem 1.25rem; font-size: 1rem; }

/* ─── FORMS ───────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}
.form-label.required::after {
  content: ' *';
  color: #ef4444;
}
.form-input,
.form-select {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:disabled,
.form-select:disabled {
  background: var(--surface-2);
  cursor: not-allowed;
  color: var(--text-muted);
}
.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-error-text {
  font-size: 0.75rem;
  color: #ef4444;
  margin-top: 4px;
}
.form-input.has-error { border-color: #ef4444; }
.form-input.has-error:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.1); }

/* ─── FILTER BAR ─────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* ─── CARDS ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}
.card-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-2);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.card-body { padding: 1.25rem; }
.card-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.card-hover {
  transition: box-shadow 0.2s, transform 0.15s;
  cursor: pointer;
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ─── BADGE ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  flex-shrink: 0;
}

/* ─── EMPTY STATE ────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1rem;
  text-align: center;
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  background: var(--surface-3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.empty-state-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.25rem;
}
.empty-state-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 28ch;
  line-height: 1.5;
}

/* ─── SKELETON LOADING ───────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--border-light) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* ─── HIDE ON MOBILE ─────────────────────────────────── */
@media (max-width: 640px) {
  .hide-mobile { display: none; }
  .page-header { flex-direction: column; }
  .data-table thead th,
  .data-table tbody td { padding: 0.5rem 0.625rem; }
}

/* ─── SCROLLBAR ──────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ─── FLATPICKR ──────────────────────────────────────── */
.flatpickr-calendar { font-family: inherit; border-radius: var(--radius-md) !important; }
.flatpickr-day.selected { background: var(--brand) !important; border-color: var(--brand) !important; }

/* ─── SIDEBAR OPEN STATE ─────────────────────────────── */
#sidebar.sidebar-open { transform: translateX(0) !important; }

/* ─── BRAND UTILITIES ────────────────────────────────── */
.text-brand        { color: var(--brand); }
.bg-brand          { background-color: var(--brand); }
.border-brand      { border-color: var(--brand); }
.bg-brand-dark     { background-color: var(--brand-dark); }
.bg-brand-light    { background-color: var(--brand-light); }
.hover\:bg-brand-dark:hover { background-color: var(--brand-dark); }

/* ─── SECTION DIVIDER ────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border-light);
  margin: 1.25rem 0;
}

/* ─── FOCUS RING ─────────────────────────────────────── */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ─── STATUS INDICATOR ───────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.online  { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,0.2); }
.status-dot.away    { background: #f59e0b; }
.status-dot.offline { background: #d1d5db; }

/* ─── INLINE SPINNER ─────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
.spinner.dark {
  border-color: rgba(29,78,216,0.2);
  border-top-color: var(--brand);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── PILL TABS ──────────────────────────────────────── */
.pill-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-3);
  padding: 4px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  scrollbar-width: none;
}
.pill-tabs::-webkit-scrollbar { display: none; }
.pill-tab {
  flex-shrink: 0;
  padding: 0.375rem 0.875rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.pill-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* ─── TOOLTIP ────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── TABLE RESPONSIVE ───────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}
.table-wrapper table {
  min-width: 100%;
  border-collapse: collapse;
}
