@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Manrope:wght@400;500;600;700&display=swap");

:root {
  --bg-base: #070b12;
  --bg-soft: #0d1420;
  --panel: #121b2a;
  --panel-strong: #172236;
  --surface: #1b2b45;
  --text: #eaf1ff;
  --muted: #9ab0d4;
  --primary: #39d98a;
  --primary-strong: #2db26f;
  --accent: #ffbf46;
  --danger: #ff6b6b;
  --border: #2c3f5f;
  --ring: rgba(57, 217, 138, 0.35);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --radius-lg: 1.25rem;
  --radius-md: 0.9rem;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 62.5%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(900px 500px at 95% -10%, rgba(57, 217, 138, 0.18), transparent),
    radial-gradient(800px 440px at 0% 0%, rgba(77, 163, 255, 0.2), transparent),
    linear-gradient(145deg, var(--bg-base), #0b1220 60%, #0f1728);
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-family: "Outfit", sans-serif;
  letter-spacing: 0.01em;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

.container {
  width: min(138rem, 96vw);
  margin: 0 auto;
  padding: 2.4rem 1.4rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

button {
  color: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(7, 11, 18, 0.86);
  color: var(--text);
  padding: 1rem 1.1rem;
  font-size: 1.35rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 0.25rem var(--ring);
}

/* Form selects — remove OS chrome, add custom chevron */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ab0d4' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 3rem;
  cursor: pointer;
}

/* Hide native number input spinners globally. */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  display: none;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Keep native date/time picker icons visible on dark inputs across pages. */
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"] {
  color-scheme: dark;
  padding-right: 3.2rem;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.95;
  filter: brightness(0) invert(1);
}

.btn,
.btn-primary,
button[type="submit"] {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 1rem 1.4rem;
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn {
  background: rgba(27, 43, 69, 0.78);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.btn:hover,
.btn-primary:hover,
button[type="submit"]:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn:hover {
  border-color: #4f6f9f;
  background: rgba(39, 59, 92, 0.9);
}

.btn:disabled,
.btn-primary:disabled,
button[type="submit"]:disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
}

.btn-primary,
button[type="submit"] {
  background: linear-gradient(135deg, var(--primary), #5ce4a5);
  color: #052b1b;
  box-shadow: 0 10px 25px rgba(57, 217, 138, 0.3);
}

.btn:focus-visible,
.btn-primary:focus-visible,
button[type="submit"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 0.25rem var(--ring);
}

/* --- Button Loading State --- */
.btn.btn-loading-active,
.btn-primary.btn-loading-active,
button[type="submit"].btn-loading-active {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  cursor: default;
}

.btn.btn-loading-active::after,
.btn-primary.btn-loading-active::after,
button[type="submit"].btn-loading-active::after {
  content: "";
  position: absolute;
  width: 1.6rem;
  height: 1.6rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid transparent;
  animation: btn-spin 0.7s linear infinite;
}

.btn.btn-loading-active::after {
  border-color: rgba(154, 176, 212, 0.35);
  border-top-color: var(--muted);
}

.btn-primary.btn-loading-active::after,
button[type="submit"].btn-loading-active::after {
  border-color: rgba(5, 43, 27, 0.35);
  border-top-color: #052b1b;
}

@keyframes btn-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.app-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, rgba(23, 34, 54, 0.94), rgba(14, 23, 37, 0.94));
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.app-card:hover {
  border-color: #4f6f9f;
  box-shadow: 0 10px 22px rgba(4, 10, 20, 0.32);
}

.card-actions-row {
  margin-top: auto;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: stretch;
}

.card-actions-row > * {
  min-width: 0;
  flex: 1 1 14.2rem;
}

.card-actions-row .btn {
  width: 100%;
  min-width: 0;
  min-height: 4.4rem;
  padding-inline: 0.9rem;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  overflow: visible;
}

.card-actions-row .btn span {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  text-align: center;
  line-height: 1.22;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th,
table td {
  font-size: 1.3rem;
  line-height: 1.45;
}

table th {
  font-family: "Outfit", sans-serif;
  letter-spacing: 0.02em;
}

table tbody tr {
  transition: background-color 0.2s ease;
}

table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.page-title {
  margin-bottom: 1.4rem;
  font-size: clamp(2.2rem, 3vw, 3.2rem);
  color: #f5fbff;
}

.page-subtitle {
  color: var(--muted);
  font-size: 1.4rem;
}

.feedback {
  font-size: 1.3rem;
  color: var(--muted);
}

.feedback.success {
  color: #68f0ad;
}

.feedback.error {
  color: #ff8a8a;
}

.is-loading {
  position: relative;
  overflow: hidden;
}

.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, 0.1) 45%,
    rgba(255, 255, 255, 0) 70%
  );
  transform: translateX(-100%);
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

/* --- Skeleton Utilities --- */
.skeleton-shimmer {
  border-radius: 0.5rem;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.11) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s ease-in-out infinite;
}

.skeleton-text {
  height: 1.3rem;
  border-radius: 0.4rem;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.11) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s ease-in-out infinite;
}

.skeleton-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 25%,
    rgba(255, 255, 255, 0.07) 50%,
    rgba(255, 255, 255, 0.03) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s ease-in-out infinite;
}

@keyframes skeleton-sweep {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.client-search-skeletons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.2rem;
}

@media (max-width: 768px) {
  html {
    font-size: 58%;
  }

  .container {
    width: min(96vw, 100%);
    padding: 1.5rem 1rem;
  }
}

@media (max-width: 560px) {
  .card-actions-row > * {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ── Toast notifications (shared across all pages) ── */
.toast-container {
  position: fixed;
  top: 6.5rem;
  right: 1.2rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(38rem, calc(100vw - 2.4rem));
  pointer-events: none;
}

.toast-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  border-radius: 0.8rem;
  border: 1px solid transparent;
  background: rgba(20, 31, 50, 0.95);
  color: var(--text);
  font-size: 1.14rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  pointer-events: auto;
  animation: toast-slide-in 0.25s ease-out;
}

.toast-item.toast-leaving {
  animation: toast-slide-out 0.3s ease-in forwards;
}

/* Generic modifiers */
.toast-item.toast-success {
  border-color: rgba(57, 217, 138, 0.45);
  background: linear-gradient(135deg, rgba(57, 217, 138, 0.18), rgba(20, 31, 50, 0.95));
}

.toast-item.toast-error {
  border-color: rgba(255, 107, 107, 0.45);
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.18), rgba(20, 31, 50, 0.95));
}

.toast-item.toast-info {
  border-color: rgba(99, 179, 255, 0.45);
  background: linear-gradient(135deg, rgba(99, 179, 255, 0.18), rgba(20, 31, 50, 0.95));
}

/* Inventory status modifiers */
.toast-item.toast-sale {
  border-color: rgba(57, 217, 138, 0.45);
  background: linear-gradient(135deg, rgba(57, 217, 138, 0.18), rgba(20, 31, 50, 0.95));
  color: #cffff0;
}

.toast-item.toast-garage {
  border-color: rgba(99, 179, 255, 0.45);
  background: linear-gradient(135deg, rgba(99, 179, 255, 0.18), rgba(20, 31, 50, 0.95));
  color: #dcefff;
}

.toast-item.toast-dispatched {
  border-color: rgba(168, 130, 255, 0.45);
  background: linear-gradient(135deg, rgba(168, 130, 255, 0.18), rgba(20, 31, 50, 0.95));
  color: #e0d2ff;
}

.toast-item.toast-delivered {
  border-color: rgba(45, 212, 191, 0.45);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.18), rgba(20, 31, 50, 0.95));
  color: #ccfbf1;
}

.toast-item.toast-reserved {
  border-color: rgba(255, 191, 70, 0.45);
  background: linear-gradient(135deg, rgba(255, 191, 70, 0.18), rgba(20, 31, 50, 0.95));
  color: #ffe6ad;
}

.toast-msg {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
}

.toast-close:hover {
  opacity: 1;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(1.5rem); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-slide-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(1.5rem); }
}

@media (max-width: 768px) {
  .toast-container {
    top: 0;
    right: 0;
    left: 0;
    max-width: 100%;
    padding: 0.6rem 0.8rem;
    gap: 0.4rem;
  }

  .toast-item {
    border-radius: 0.7rem;
    font-size: 1.15rem;
    font-weight: 700;
    padding: 1rem 1.2rem;
    color: #ffffff;
    background: #1a2740;
    border-color: transparent;
    animation: toast-slide-down 0.25s ease-out;
  }

  .toast-item.toast-leaving {
    animation: toast-slide-up-out 0.25s ease-in forwards;
  }

  .toast-item.toast-success,
  .toast-item.toast-sale {
    background: #17a152;
    border-color: transparent;
    color: #ffffff;
  }

  .toast-item.toast-error {
    background: #c0392b;
    border-color: transparent;
    color: #ffffff;
  }

  .toast-item.toast-info,
  .toast-item.toast-garage {
    background: #1a6fa8;
    border-color: transparent;
    color: #ffffff;
  }

  .toast-item.toast-dispatched {
    background: #6b3fa0;
    border-color: transparent;
    color: #ffffff;
  }

  .toast-item.toast-delivered {
    background: #0d8a7a;
    border-color: transparent;
    color: #ffffff;
  }

  .toast-item.toast-reserved {
    background: #b07d10;
    border-color: transparent;
    color: #ffffff;
  }
}

@keyframes toast-slide-down {
  from { opacity: 0; transform: translateY(-1rem); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-slide-up-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-1rem); }
}

/* ── Custom Filter Dropdown (system-wide) ───────────────────── */

.filter-select-wrap {
  display: grid;
  gap: 0.4rem;
}

.filter-select-label {
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.filter-select {
  position: relative;
}

.filter-select-trigger {
  width: 100%;
  min-height: 4.4rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(92, 130, 194, 0.55);
  background: rgba(4, 13, 30, 0.9);
  color: var(--text);
  padding: 0.7rem 1rem;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: left;
}

.filter-select-trigger:hover,
.filter-select.open .filter-select-trigger {
  border-color: var(--primary);
}

.filter-select.open .filter-select-trigger {
  box-shadow: 0 0 0 2px var(--ring);
}

.filter-chevron {
  font-size: 1.1rem;
  color: var(--muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.filter-select.open .filter-chevron {
  transform: rotate(180deg);
}

.filter-select-dropdown {
  position: fixed;
  z-index: 1200;
  background: linear-gradient(160deg, rgba(20, 31, 50, 0.98), rgba(10, 17, 30, 0.98));
  border: 1px solid rgba(92, 130, 194, 0.5);
  border-radius: 0.8rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  max-height: 22rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(126, 166, 217, 0.35) transparent;
}

.filter-select-dropdown::-webkit-scrollbar {
  width: 6px;
}

.filter-select-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.filter-select-dropdown::-webkit-scrollbar-thumb {
  background: rgba(126, 166, 217, 0.35);
  border-radius: 999px;
}

.filter-select-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(126, 166, 217, 0.55);
}

/* Mobile filter drawer backdrop */
.filters-mobile-overlay {
  display: none;
}

@media (max-width: 980px) {
  .filters-mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 79;
    background: rgba(5, 10, 18, 0.55);
  }
}

.filter-select-option {
  width: 100%;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(92, 130, 194, 0.12);
}

.filter-select-option:last-child {
  border-bottom: none;
}

.filter-select-option:hover {
  background: rgba(57, 217, 138, 0.1);
  color: var(--primary);
}

.filter-select-option.active {
  background: rgba(57, 217, 138, 0.15);
  color: var(--primary);
  font-weight: 600;
}
