/*
 * Motor Sights Fleet CRM — component styles
 * Plain CSS (the Tailwind Play CDN ignores @apply in external files).
 * Dark variants are written as `.dark .selector`. See docs/DESIGN-SYSTEM.md.
 */

/* ---------- Base ---------- */
html { color-scheme: light; }
html.dark { color-scheme: dark; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
.dark ::-webkit-scrollbar-thumb { background: #404040; }
.dark ::-webkit-scrollbar-thumb:hover { background: #525252; }

.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ---------- Navigation ---------- */
.nav-tab {
  font-size: 13px; font-weight: 500; color: #9ca3af;
  white-space: nowrap; transition: color 150ms ease;
}
.nav-tab:hover { color: #111827; }
.nav-tab.active { color: #111827; font-weight: 600; }
.dark .nav-tab { color: #737373; }
.dark .nav-tab:hover,
.dark .nav-tab.active { color: #fff; }

/* ---------- Cards ---------- */
.card {
  background: #fff; border: 1px solid #f3f4f6; border-radius: .75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.dark .card { background: #171717; border-color: #262626; box-shadow: none; }

.card-label {
  font-size: .75rem; line-height: 1rem; font-weight: 600; color: #9ca3af;
  text-transform: uppercase; letter-spacing: .1em;
}
.card-header {
  margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid #f3f4f6;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.dark .card-header { border-color: #262626; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  padding: .5rem 1rem; border-radius: .5rem; border: 1px solid transparent;
  font-size: .875rem; line-height: 1.25rem; font-weight: 500; white-space: nowrap;
  cursor: pointer; transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }

.btn-primary { background: #111827; color: #fff; }
.btn-primary:hover { background: #374151; }
.dark .btn-primary { background: #f5f5f5; color: #171717; }
.dark .btn-primary:hover { background: #fff; }

.btn-secondary { border-color: #d1d5db; color: #374151; }
.btn-secondary:hover { background: #f3f4f6; }
.dark .btn-secondary { border-color: #525252; color: #d4d4d4; }
.dark .btn-secondary:hover { background: #262626; }

.btn-ghost { padding-left: 1.25rem; padding-right: 1.25rem; color: #4b5563; }
.btn-ghost:hover { background: #f3f4f6; }
.dark .btn-ghost { color: #a3a3a3; }
.dark .btn-ghost:hover { background: #404040; }

.row-action {
  font-size: .75rem; font-weight: 500; color: #9ca3af;
  padding: .25rem .5rem; border-radius: .25rem; transition: color 150ms ease, background-color 150ms ease;
}
.row-action:hover { color: #111827; background: #f3f4f6; }
.row-action.danger:hover { color: #dc2626; background: #fef2f2; }
.dark .row-action:hover { color: #fff; background: #262626; }
.dark .row-action.danger:hover { color: #f87171; background: rgba(248, 113, 113, .1); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: .5rem; color: #6b7280;
  transition: color 150ms ease, background-color 150ms ease;
}
.icon-btn:hover { color: #111827; background: #f3f4f6; }
.dark .icon-btn { color: #a3a3a3; }
.dark .icon-btn:hover { color: #fff; background: #262626; }

/* ---------- Form controls ---------- */
.toolbar-input {
  border: 1px solid #e5e7eb; background: #fff; color: #111827;
  border-radius: .5rem; padding: .5rem .75rem; font-size: .875rem; line-height: 1.25rem;
  outline: none; transition: box-shadow 150ms ease;
}
.toolbar-input:focus { box-shadow: 0 0 0 1px #9ca3af; }
.toolbar-input::placeholder { color: #9ca3af; }
.dark .toolbar-input { border-color: #404040; background: #262626; color: #f5f5f5; }
.dark .toolbar-input::placeholder { color: #737373; }
.dark .toolbar-input:focus { box-shadow: 0 0 0 1px #737373; }

.form-label {
  display: block; margin-bottom: .5rem;
  font-size: .75rem; line-height: 1rem; font-weight: 700; color: #6b7280; text-transform: uppercase;
}
.dark .form-label { color: #a3a3a3; }

.form-input {
  display: block; width: 100%; padding: .75rem; border: 2px solid #e5e7eb; border-radius: .75rem;
  background: #f9fafb; color: #111827; font-size: .875rem; line-height: 1.25rem;
  outline: none; transition: border-color 150ms ease;
}
.form-input:focus { border-color: #9ca3af; }
.form-input::placeholder { color: #9ca3af; }
.dark .form-input { border-color: #404040; background: #262626; color: #f5f5f5; }
.dark .form-input:focus { border-color: #737373; }
.dark .form-input::placeholder { color: #737373; }

.form-section + .form-section { margin-top: 2rem; }

.swatch {
  width: 1.5rem; height: 1.5rem; border-radius: 9999px; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); transition: transform 100ms ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.selected { outline: 2px solid #111827; outline-offset: 2px; }
.dark .swatch.selected { outline-color: #f5f5f5; }

/* ---------- Badges ---------- */
.status-pill {
  display: inline-flex; align-items: center; padding: .25rem .75rem; border-radius: 9999px;
  font-size: 12px; line-height: 1rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .025em; white-space: nowrap;
}
.category-badge {
  display: inline-block; padding: .125rem .5rem; border-radius: .25rem;
  font-size: 12px; line-height: 1rem; font-weight: 700; text-transform: uppercase; white-space: nowrap;
}

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; max-height: 65vh; }
.table-counter {
  font-size: .75rem; line-height: 1rem; font-weight: 500; color: #9ca3af;
  text-transform: uppercase; letter-spacing: .025em; white-space: nowrap;
}

.data-table { width: 100%; font-size: .875rem; line-height: 1.25rem; border-collapse: separate; border-spacing: 0; }
.data-table th {
  position: sticky; top: 0; z-index: 1;
  padding: 14px 18px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: .05em;
  background: #f3f4f6; box-shadow: 0 2px 4px rgba(0, 0, 0, .08);
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: #111827; }
.data-table td { padding: 14px 18px; white-space: nowrap; color: #4b5563; border-top: 1px solid #f9fafb; }
.data-table tbody tr:first-child td { border-top: 0; }
.data-table tbody tr:hover td { background: #f9fafb; }
.data-table .cell-primary { color: #111827; font-weight: 500; }
.data-table .cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .75rem; font-weight: 600; }
.data-table .cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .cell-date { font-variant-numeric: tabular-nums; }
.data-table .cell-actions { text-align: right; }
.data-table .cell-empty { padding: 2.5rem 18px; text-align: center; color: #9ca3af; font-style: italic; }

.dark .data-table th { background: #1f1f1f; color: #a3a3a3; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); }
.dark .data-table th.sortable:hover { color: #fff; }
.dark .data-table td { color: #d4d4d4; border-top-color: rgba(38, 38, 38, .7); }
.dark .data-table tbody tr:hover td { background: rgba(38, 38, 38, .5); }
.dark .data-table .cell-primary { color: #f5f5f5; }
.dark .data-table .cell-empty { color: #737373; }

.muted-dash { color: #d1d5db; }
.dark .muted-dash { color: #525252; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; align-items: center; justify-content: flex-end; gap: .25rem;
  padding: .75rem 1rem; border-top: 1px solid #f3f4f6;
}
.pagination:empty { display: none; }
.dark .pagination { border-color: #262626; }

.page-btn {
  padding: .375rem .75rem; border: 1px solid #e5e7eb; border-radius: .375rem;
  font-size: .875rem; line-height: 1.25rem; font-weight: 500; color: #4b5563; font-variant-numeric: tabular-nums;
}
.page-btn:hover:not(:disabled):not(.active) { background: #f9fafb; }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }
.page-btn.active { background: #111827; border-color: #111827; color: #fff; }
.dark .page-btn { border-color: #404040; color: #a3a3a3; }
.dark .page-btn:hover:not(:disabled):not(.active) { background: #262626; }
.dark .page-btn.active { background: #f5f5f5; border-color: #f5f5f5; color: #171717; }
.page-gap { padding: 0 .25rem; color: #9ca3af; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999; padding: 1rem;
  background: rgba(0, 0, 0, .8); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}

/* ---------- Kanban ---------- */
.kanban-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.kanban-column {
  flex: 0 0 18rem; display: flex; flex-direction: column;
  height: calc(100vh - 13rem); min-height: 28rem;
  background: rgba(243, 244, 246, .7); border: 1px solid #e5e7eb; border-radius: .75rem;
}
.dark .kanban-column { background: #171717; border-color: #262626; }
.kanban-card {
  cursor: grab; background: #fff; border: 1px solid #f3f4f6; border-radius: .5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05); padding: .875rem;
}
.kanban-card:hover { border-color: #e5e7eb; }
.dark .kanban-card { background: #262626; border-color: #333; box-shadow: none; }
.dark .kanban-card:hover { border-color: #404040; }
.kanban-card.sortable-ghost { opacity: .4; }
.kanban-card.sortable-chosen { cursor: grabbing; }

/* ---------- Loading + toast ---------- */
.spinner {
  width: 2rem; height: 2rem; border-radius: 9999px;
  border: 2px solid #e5e7eb; border-top-color: #111827; animation: spin .7s linear infinite;
}
.dark .spinner { border-color: #404040; border-top-color: #f5f5f5; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 10000; max-width: 22rem;
  padding: .625rem 1rem; border-radius: .5rem; font-size: .8125rem; line-height: 1.25rem; font-weight: 500;
  background: #111827; color: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
  opacity: 0; transform: translateY(.5rem); pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-left: 3px solid #dc2626; }
.dark .toast { background: #f5f5f5; color: #171717; box-shadow: 0 4px 12px rgba(0, 0, 0, .5); }
.dark .toast-error { border-left-color: #f87171; }

/* ---------- FullCalendar ---------- */
.fc {
  --fc-border-color: #f3f4f6;
  --fc-page-bg-color: #fff;
  --fc-neutral-bg-color: #f9fafb;
  --fc-today-bg-color: #f9fafb;
  --fc-list-event-hover-bg-color: #f9fafb;
  --fc-button-text-color: #374151;
  --fc-button-bg-color: #fff;
  --fc-button-border-color: #d1d5db;
  --fc-button-hover-bg-color: #f3f4f6;
  --fc-button-hover-border-color: #d1d5db;
  --fc-button-active-bg-color: #111827;
  --fc-button-active-border-color: #111827;
  font-size: .8125rem;
}
.dark .fc {
  --fc-border-color: #262626;
  --fc-page-bg-color: #171717;
  --fc-neutral-bg-color: #1f1f1f;
  --fc-today-bg-color: #1f1f1f;
  --fc-list-event-hover-bg-color: #262626;
  --fc-button-text-color: #d4d4d4;
  --fc-button-bg-color: #171717;
  --fc-button-border-color: #525252;
  --fc-button-hover-bg-color: #262626;
  --fc-button-hover-border-color: #525252;
  --fc-button-active-bg-color: #f5f5f5;
  --fc-button-active-border-color: #f5f5f5;
}
.fc a { color: inherit; text-decoration: none; }
.fc .fc-toolbar-title { font-size: 1rem; font-weight: 700; color: #111827; }
.dark .fc .fc-toolbar-title { color: #fff; }
.fc .fc-button {
  font-size: .8125rem; font-weight: 500; padding: .375rem .75rem; border-radius: .5rem;
  text-transform: capitalize; box-shadow: none !important;
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { color: #fff; }
.dark .fc .fc-button-primary:not(:disabled).fc-button-active,
.dark .fc .fc-button-primary:not(:disabled):active { color: #171717; }
.fc .fc-button-primary:disabled { opacity: .4; }
.fc .fc-col-header-cell-cushion {
  padding: .5rem .25rem; font-size: 11px; font-weight: 600; color: #9ca3af;
  text-transform: uppercase; letter-spacing: .05em;
}
.fc .fc-daygrid-day-number { font-size: .75rem; color: #6b7280; font-variant-numeric: tabular-nums; }
.dark .fc .fc-daygrid-day-number { color: #a3a3a3; }
.fc .fc-day-today .fc-daygrid-day-number { color: #111827; font-weight: 700; }
.dark .fc .fc-day-today .fc-daygrid-day-number { color: #fff; }
.fc .fc-daygrid-event { border-radius: .25rem; font-size: 11px; font-weight: 500; padding: 1px 4px; }
.fc .fc-list-day-cushion { font-size: .75rem; font-weight: 600; }
.fc .fc-list-event-title, .fc .fc-list-event-time { color: #374151; }
.dark .fc .fc-list-event-title, .dark .fc .fc-list-event-time { color: #d4d4d4; }
