/* ========== GLOBAL RESET ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #050608;
  color: #f5f5f5;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ========== APP SHELL ========== */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== HEADER ========== */
.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #222;
  background: #050608;
}

.app-header img.logo {
  height: 40px;
  width: 40px;
  border-radius: 999px;
  object-fit: cover;
}

.app-header .titles {
  display: flex;
  flex-direction: column;
}

.app-header .brand {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  font-weight: 600;
  text-transform: uppercase;
}

.app-header .subtitle {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #a0a0a0;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.role-pill {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #444;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ccc;
}

/* PQI toggle in header */
.pqi-toggle-global {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #3b82f6;
  background: #020617;
  color: #bfdbfe;
  font-size: 0.7rem;
  cursor: pointer;
}
.pqi-toggle-global.off {
  border-color: #374151;
  background: #020617;
  color: #9ca3af;
}

/* ========== MAIN LAYOUT ========== */
.app-main {
  padding: 0.75rem 1rem 1.5rem;
  max-width: 1800px;
  margin: 0 auto;
}

.app-main-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 3-column layout */
.layout-grid {
  display: grid;
  grid-template-columns: minmax(120px, 7%) minmax(0, 86%) minmax(120px, 7%);
  gap: 0.75rem;
  align-items: flex-start;
}

.layout-left,
.layout-center,
.layout-right {
  min-width: 0;
}

/* ========== SECTIONS / TITLES ========== */
.section {
  margin-bottom: 1rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.section-subtitle {
  font-size: 0.8rem;
  color: #a0a0a0;
}

/* Small blue count pill */
.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  padding: 0.06rem 0.4rem;
  border-radius: 999px;
  border: 1px solid #60a5fa;
  background: #0b1c3a;
  font-size: 0.75rem;
  color: #dbeafe;
  font-weight: 600;
}

/* ========== BUTTONS / CHIPS ========== */
.btn {
  border-radius: 999px;
  border: 1px solid #f5f5f5;
  background: transparent;
  color: #f5f5f5;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover {
  background: #f5f5f5;
  color: #050608;
}

.btn-primary {
  font-weight: 600;
}

.btn.small {
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
}

/* Shared blue pill style for any "selected" button */
.btn.selected,
.btn.active,
.btn.is-active,
.btn.is-selected,
.keys-buttons .btn.selected,
.wash-buttons .btn.selected {
  border-radius: 999px;
  border: 1px solid #60a5fa;
  background: #0b1c3a;
  color: #dbeafe;
  font-weight: 600;
}

/* Generic pill */
.pill-blue {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid #60a5fa;
  background: #0b1c3a;
  color: #dbeafe;
  font-weight: 700;
}

/* Keys (valet names) group */
.keys-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}
.keys-buttons .btn {
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: transparent;
  padding: 0.15rem 0.45rem;
  font-size: 0.74rem;
}
.keys-buttons .btn:hover {
  border-color: #9ca3af;
}

/* Status/location options group */
.wash-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}
.wash-buttons .btn {
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: transparent;
  padding: 0.15rem 0.5rem;
  font-size: 0.74rem;
}
.wash-buttons .btn:hover {
  border-color: #9ca3af;
}

/* Notes "Add note" button – keep rectangular */
.notes-button {
  border-radius: 4px;
  border-style: solid;
  border-color: #4b5563;
  background: transparent;
}

/* ========== NEW PICKUP FORM (DISPATCH) ========== */
.new-pickup-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  background: #0a0b10;
  border-radius: 10px;
  border: 1px solid #191b22;
  padding: 0.45rem 0.7rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.input-group label {
  font-size: 0.72rem;
  color: #b0b0b0;
}

.input-text {
  background: #030307;
  border-radius: 6px;
  border: 1px solid #2b2e3a;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  color: #f5f5f5;
  min-width: 150px;
}

.input-text::placeholder {
  color: #555;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: #b0b0b0;
}

/* ========== SCREEN LINKS ========== */
.screen-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ========== TABLE WRAPPERS ========== */
.table-wrapper {
  background: #06060c;
  border-radius: 10px;
  border: 1px solid #181820;
  overflow-y: auto;
}

/* ACTIVE PICKUPS highlight – animated border */
.section-active .table-wrapper {
  position: relative;
  border-width: 4px;
  border-color: #e5e7eb;
}
.section-active .table-wrapper::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 3px solid transparent;
  background: conic-gradient(
    from 0deg,
    rgba(255, 255, 255, 0.9),
    rgba(148, 163, 184, 0.25),
    rgba(255, 255, 255, 0.9)
  );
  background-size: 200% 200%;
  animation: borderFlow 4s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 0;
}
@keyframes borderFlow {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

.table-wrapper.small {
  max-height: 280px;
}

/* Staged column wrapper needs its own scroll & width behaviour */
.section-staged .table-wrapper {
  max-height: 260px;
  overflow-y: auto;
  overflow-x: auto;
}

/* ========== TABLE BASE STYLES ========== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  table-layout: fixed;
}

thead {
  background: #101018;
}

th,
td {
  padding: 0.3rem 0.45rem;
  border-bottom: 1px solid #17171f;
  text-align: left;
}

th {
  white-space: nowrap;
  font-weight: 500;
  color: #ccc;
}

td {
  white-space: normal;
  color: #f5f5f5;
  vertical-align: top;
}

tr:nth-child(even) td {
  background: #05050b;
}

/* ========== TAG / CUSTOMER (FIX: NO MORE GIANT CIRCLES) ========== */
/*
  These classes are applied directly on <td>.
  Styling a <td> like an inline pill breaks table layout and can render as giant circles.
  So: keep them as normal table cells, just give them readable emphasis.
*/
td.cell-tag,
td.cell-customer {
  display: table-cell;
  border: none;
  background: transparent;
  border-radius: 0;
  font-weight: 700;
  color: #dbeafe;
  white-space: nowrap;
}

/* If you later wrap text in <span class="pill-blue">, it will look like the pill you want. */

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid #3a3a3a;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #d0d0d0;
}

/* ========== NOTES AREA ========== */
.notes-preview {
  font-size: 0.7rem;
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #60a5fa;
  background: #0b1c3a;
  color: #dbeafe;
}

/* ========== TIMERS ========== */
.timer {
  font-family: "Menlo", "Consolas", monospace;
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-block;
}

.timer-green { border-color: #204d2a; background: #0b1b10; color: #a9ffb7; }
.timer-yellow { border-color: #5c5213; background: #1b1808; color: #ffe28a; }
.timer-orange { border-color: #7a4418; background: #221109; color: #ffb47a; }
.timer-red { border-color: #7a1c1c; background: #220a0a; color: #ff9b9b; }

/* Needs rewash – flashing blue pill */
.wash-needs {
  border-radius: 999px;
  border: 1px solid #60a5fa;
  background: #0b1c3a;
  color: #dbeafe;
  animation: washBlink 0.7s infinite;
}
@keyframes washBlink {
  0% { border-color: #60a5fa; background: #0b1c3a; box-shadow: 0 0 0 0 rgba(59,130,246,0.9); }
  50% { border-color: #bfdbfe; background: #1d4ed8; box-shadow: 0 0 18px 7px rgba(59,130,246,0.95); }
  100% { border-color: #60a5fa; background: #0b1c3a; box-shadow: 0 0 0 0 rgba(59,130,246,0.9); }
}

/* ========== EMPTY STATE ========== */
.empty {
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: #888;
}

/* ========== ROLE VISIBILITY ========== */
body.role-dispatcher .dispatcher-only { display: initial; }
body.role-dispatcher th.dispatcher-only,
body.role-dispatcher td.dispatcher-only { display: table-cell; }

body.role-keymachine .dispatcher-only,
body.role-carwash .dispatcher-only,
body.role-wallboard .dispatcher-only,
body.role-serviceadvisor .dispatcher-only,
body.role-loancar .dispatcher-only {
  display: none !important;
}

body.role-keymachine .keymachine-only,
body.role-dispatcher .keymachine-only,
body.role-carwash .keymachine-only { display: initial; }

body.role-wallboard .keymachine-only,
body.role-serviceadvisor .keymachine-only,
body.role-loancar .keymachine-only {
  display: none !important;
}

body.role-carwash .carwash-only { display: initial; }
body.role-serviceadvisor .carwash-only,
body.role-loancar .carwash-only { display: none !important; }

/* Wallboard styling */
.wallboard-main { max-width: 1600px; }
.wallboard-table th,
.wallboard-table td {
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
}

/* Wallboard read-only */
body.role-wallboard button {
  pointer-events: none;
  opacity: 0.7;
}

/* ========== HARD UI LOCK FOR SERVICEADVISOR + LOANCAR ========== */
body.role-serviceadvisor .wash-buttons,
body.role-serviceadvisor .keys-buttons,
body.role-serviceadvisor button[data-action^="toggle-"],
body.role-loancar .wash-buttons,
body.role-loancar .keys-buttons,
body.role-loancar button[data-action^="toggle-"] {
  display: none !important;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  .layout-grid { display: block; }
  .layout-left,
  .layout-center,
  .layout-right { margin-bottom: 1rem; }
}

@media (max-width: 900px) {
  .app-main { padding: 0.75rem 0.75rem 1.5rem; }
  .new-pickup-form { flex-direction: column; }
  th, td { padding: 0.4rem 0.45rem; }
}
