/* =========================================================
   WorkBay — Workshop Job Control
   Design tokens
   ========================================================= */
:root{
  --bg:            #11161C;
  --panel:         #1B232C;
  --panel-raised:  #212B35;
  --border:        #2A3540;
  --border-soft:   #233039;
  --amber:         #F2A33D;
  --amber-dim:     #6B5026;
  --green:         #5CC8A0;
  --green-dim:     #295046;
  --red:           #E0654F;
  --red-dim:       #5C2E26;
  --text:          #E2E8ED;
  --text-dim:      #7C8896;
  --text-faint:    #4E5A66;

  --font-display: 'Barlow Condensed', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 6px;
  --shadow-drawer: -24px 0 48px rgba(0,0,0,0.45);
}

*{ box-sizing: border-box; }
html, body{ margin:0; padding:0; }

body{
  background: var(--bg);
  background-image:
    radial-gradient(circle at 100% 0%, rgba(242,163,61,0.05), transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(92,200,160,0.04), transparent 50%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden{ display:none !important; }

button{ font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea{ font-family: inherit; }

/* =========================================================
   TOP BAR
   ========================================================= */
.topbar{
  height: 60px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar-brand{ display:flex; align-items:center; gap:12px; }
.brand-mark{
  width:34px; height:34px;
  border:1.5px solid var(--amber);
  border-radius: 4px;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-mono);
  font-weight:700;
  font-size:13px;
  color: var(--amber);
  letter-spacing: 0.5px;
}
.brand-text{ display:flex; flex-direction:column; line-height:1.1; }
.brand-name{ font-family: var(--font-display); font-weight:700; font-size:19px; letter-spacing:0.3px; }
.brand-sub{ font-size:10.5px; color: var(--text-dim); text-transform:uppercase; letter-spacing:1.4px; }

.topbar-status{
  display:flex; align-items:center; gap:8px;
  font-size:12.5px; color: var(--text-dim);
  font-family: var(--font-mono);
}
.conn-dot{
  width:7px; height:7px; border-radius:50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 0 rgba(92,200,160,0.5);
}
.conn-dot.online{ background: var(--green); animation: pulse 2s infinite; }
.conn-dot.offline{ background: var(--red); }
@keyframes pulse{
  0%{ box-shadow: 0 0 0 0 rgba(92,200,160,0.45); }
  70%{ box-shadow: 0 0 0 6px rgba(92,200,160,0); }
  100%{ box-shadow: 0 0 0 0 rgba(92,200,160,0); }
}

.topbar-right{ display:flex; align-items:center; gap:14px; }
.role-chip{
  font-family: var(--font-mono);
  font-size:11.5px;
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--amber);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.btn-ghost{
  font-size:13px; color: var(--text-dim);
  padding: 7px 12px; border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all .15s ease;
}
.btn-ghost:hover{ color: var(--text); border-color: var(--text-faint); }

/* =========================================================
   ROLE SELECT SCREEN
   ========================================================= */
.screen{ width:100%; }
.screen-select{
  min-height: calc(100vh - 60px);
  display:flex; align-items:center; justify-content:center;
  padding: 40px 24px;
}
.select-wrap{ text-align:center; max-width: 980px; }
.eyebrow{
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 10px;
}
.select-title{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 5vw, 52px);
  margin: 0 0 40px;
  letter-spacing: 0.3px;
}

.role-tiles{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 22px;
}
@media (max-width: 900px){ .role-tiles{ grid-template-columns: 1fr 1fr; } }
@media (max-width: 680px){ .role-tiles{ grid-template-columns: 1fr; } }

.admin-entry-link{
  display: inline-block;
  margin-top: 36px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.admin-entry-link:hover{ color: var(--text-dim); border-color: var(--border); }

.role-tile{
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 28px;
  display:flex; flex-direction:column; align-items:center; gap:10px;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.role-tile:hover{
  transform: translateY(-3px);
  border-color: var(--amber);
  background: var(--panel-raised);
}
.role-tile:focus-visible{ outline: 2px solid var(--amber); outline-offset: 2px; }

.tile-bracket{
  position:absolute; width:16px; height:16px;
  border: 2px solid var(--text-faint);
  opacity: .6;
  transition: border-color .18s ease;
}
.role-tile:hover .tile-bracket{ border-color: var(--amber); }
.tile-bracket.tl{ top:10px; left:10px; border-right:none; border-bottom:none; }
.tile-bracket.tr{ top:10px; right:10px; border-left:none; border-bottom:none; }
.tile-bracket.bl{ bottom:10px; left:10px; border-right:none; border-top:none; }
.tile-bracket.br{ bottom:10px; right:10px; border-left:none; border-top:none; }

.tile-icon{
  font-family: var(--font-mono);
  font-weight:700;
  font-size: 22px;
  color: var(--amber);
  border: 1.5px solid var(--amber-dim);
  width:56px; height:56px;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  margin-bottom: 6px;
}
.tile-label{
  font-family: var(--font-display);
  font-weight:600;
  font-size: 22px;
}
.tile-desc{ font-size: 13px; color: var(--text-dim); }

/* =========================================================
   WORKSPACE SCREEN
   ========================================================= */
.screen-workspace{ padding: 28px 32px 60px; max-width: 1400px; margin: 0 auto; }
.workspace-head{
  display:flex; align-items:flex-end; justify-content:space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 16px;
}

.filter-bar{
  display:flex; align-items:center; gap:8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filter-chip{
  font-size: 12px; font-weight:500;
  padding: 6px 13px;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--panel);
  white-space: nowrap;
  transition: all .15s ease;
}
.filter-chip:hover{ border-color: var(--text-faint); color: var(--text); }
.filter-chip.active{
  background: var(--amber);
  border-color: var(--amber);
  color: #1A1304;
  font-weight: 600;
}
.workspace-title{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  margin: 2px 0 0;
}

.workspace-actions{
  display:flex; align-items:center; gap:10px;
}
.search-input{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font-mono);
  width: 220px;
  outline: none;
  transition: border-color .15s ease;
}
.search-input::placeholder{ color: var(--text-faint); font-family: var(--font-body); }
.search-input:focus{ border-color: var(--amber); }

.btn-primary{
  background: var(--amber);
  color: #1A1304;
  font-weight:600;
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: var(--radius);
  transition: filter .15s ease;
}
.btn-primary:hover{ filter: brightness(1.08); }

.btn-secondary{
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight:500;
  font-size: 13.5px;
  padding: 11px 16px;
  border-radius: var(--radius);
  transition: border-color .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn-secondary:hover{ border-color: var(--green); background: var(--panel-raised); }

.btn-danger{
  color: var(--red);
  border: 1px solid var(--red-dim);
  font-size: 13px;
  padding: 9px 14px;
  border-radius: var(--radius);
  transition: background .15s ease;
}
.btn-danger:hover{ background: rgba(224,101,79,0.1); }

/* =========================================================
   TABLE
   ========================================================= */
.table-shell{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.job-table{
  width:100%;
  min-width: 1100px; /* prevents columns from squeezing illegibly thin before the scrollbar kicks in */
  border-collapse: collapse;
  font-size: 13.5px;
}
.job-table thead th{
  text-align:left;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 500;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.job-table tbody tr{
  border-bottom: 1px solid var(--border-soft);
  transition: background .12s ease;
  cursor: pointer;
}
.job-table tbody tr:last-child{ border-bottom:none; }
.job-table tbody tr:hover{ background: rgba(242,163,61,0.05); }
.job-table tbody td{
  padding: 13px 16px;
  vertical-align: middle;
}
.job-table tbody td:first-child{
  border-left: 3px solid var(--text-faint);
}
.row-status-amber td:first-child{ border-left-color: var(--amber); }
.row-status-green td:first-child{ border-left-color: var(--green); }
.row-status-red td:first-child{ border-left-color: var(--red); }

.cell-mono{ font-family: var(--font-mono); color: var(--text); }
.cell-dim{ color: var(--text-dim); }

.status-pill{
  display:inline-flex; align-items:center; gap:6px;
  font-size: 12px; font-weight:500;
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
}
.status-pill::before{ content:''; width:6px; height:6px; border-radius:50%; }
.status-pill.amber{ background: rgba(242,163,61,0.12); color: var(--amber); }
.status-pill.amber::before{ background: var(--amber); }
.status-pill.green{ background: rgba(92,200,160,0.12); color: var(--green); }
.status-pill.green::before{ background: var(--green); }
.status-pill.red{ background: rgba(224,101,79,0.12); color: var(--red); }
.status-pill.red::before{ background: var(--red); }
.status-pill.neutral{ background: rgba(124,136,150,0.12); color: var(--text-dim); }
.status-pill.neutral::before{ background: var(--text-faint); }

.empty-state{ padding: 70px 20px; text-align:center; }
.empty-title{ font-family: var(--font-display); font-size:20px; font-weight:600; margin:0 0 6px; }
.empty-sub{ color: var(--text-dim); font-size: 13.5px; margin:0; }

/* =========================================================
   DRAWER (Add / Edit job card)
   ========================================================= */
.drawer-overlay{
  position: fixed; inset:0;
  background: rgba(0,0,0,0.5);
  display:flex; justify-content:flex-end;
  z-index: 100;
}
.drawer{
  width: min(460px, 100%);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-drawer);
  display:flex; flex-direction:column;
  animation: slideIn .2s ease;
}
@keyframes slideIn{ from{ transform: translateX(24px); opacity:0; } to{ transform: translateX(0); opacity:1; } }

.drawer-head{
  display:flex; align-items:center; justify-content:space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h3{ font-family: var(--font-display); font-size: 21px; font-weight:600; margin:0; }
.btn-icon{ color: var(--text-dim); font-size: 16px; padding:4px; }
.btn-icon:hover{ color: var(--text); }

.drawer-body{ padding: 20px 22px; overflow-y:auto; flex:1; display:flex; flex-direction:column; gap:16px; }

.field{ display:flex; flex-direction:column; gap:6px; }
.field label{
  font-size: 11.5px; text-transform:uppercase; letter-spacing:0.8px;
  color: var(--text-dim); font-weight:500;
}
.field input, .field select, .field textarea{
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus{ border-color: var(--amber); }
.field textarea{ resize: vertical; min-height: 64px; }
.field-mono input{ font-family: var(--font-mono); }
.field-locked input, .field-locked select{
  opacity: 0.55; cursor: not-allowed;
}
.field-hint{ font-size: 11px; color: var(--text-faint); }

.courtesy-block{
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
}
.courtesy-toggle-row{
  display:flex; align-items:center; justify-content:space-between;
  gap: 10px; flex-wrap: wrap;
}
.courtesy-toggle-row > span{ font-size: 13.5px; color: var(--text); }
.courtesy-toggle-btns{ display:flex; gap: 6px; }
.courtesy-issue-area select{
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13.5px;
}
.courtesy-active-info{
  background: var(--panel-raised);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.drawer-foot{
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
}
.drawer-foot-right{ display:flex; gap:10px; }

/* =========================================================
   TOAST
   ========================================================= */
.toast{
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
}
.toast.error{ border-color: var(--red-dim); color: var(--red); }
.toast.success{ border-color: var(--green-dim); color: var(--green); }

/* =========================================================
   MOBILE (≤ 768px)
   The data table converts into a stacked card list — each
   job card becomes one block, keeping the same colored status
   rail. Drawer becomes a full-screen sheet instead of a side
   panel, since 460px doesn't fit a phone. Filter chips and
   search scroll/stack rather than overflow the header.
   ========================================================= */
@media (max-width: 768px){

  .fleet-grid{ grid-template-columns: 1fr 1fr; gap: 10px; }
  .fleet-card{ padding: 12px; }
  .fleet-reg{ font-size: 13.5px; }
  .section-divider{ margin: 28px 0 16px; }

  .topbar{ padding: 0 14px; height: 54px; }
  .brand-sub{ display:none; }
  .topbar-status #connLabel{ display:none; } /* keep the dot, drop the text label */
  .topbar-right{ gap: 8px; }
  .role-chip{ display:none; } /* role already obvious from the screen title below */
  .btn-ghost{ font-size: 12px; padding: 6px 9px; }

  .screen-select{ padding: 24px 16px; min-height: calc(100vh - 54px); }
  .select-title{ font-size: 28px; margin-bottom: 28px; }
  .role-tile{ padding: 32px 20px; }

  .screen-workspace{ padding: 18px 14px 40px; }
  .workspace-head{ flex-direction: column; align-items: stretch; margin-bottom: 16px; }
  .workspace-title{ font-size: 24px; }
  .workspace-actions{ flex-direction: column; align-items: stretch; gap: 8px; }
  .search-input{ width: 100%; }
  .btn-primary{ width: 100%; text-align:center; padding: 12px 18px; }
  .btn-secondary{ width: 100%; text-align:center; }

  .filter-bar{
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px 16px;
    padding: 0 14px 4px;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar{ display:none; }
  .filter-chip{ flex-shrink: 0; padding: 9px 14px; }

  /* ---- table → stacked cards ---- */
  .table-shell{ background: transparent; border: none; overflow-x: visible; }
  .job-table{ min-width: 0; }
  .job-table thead{ display:none; }
  .job-table, .job-table tbody{ display:block; width:100%; }
  .job-table tbody tr{
    display:block;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
  }
  .job-table tbody tr:last-child{ margin-bottom:0; }
  .job-table tbody td{
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    border-left: none !important; /* status color moves to a top rail instead */
  }
  .job-table tbody td:last-child{ border-bottom: none; }
  .job-table tbody td::before{
    content: attr(data-label);
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-dim);
    flex-shrink: 0;
  }
  .job-table tbody td > *{ text-align:right; }

  /* status color rail moves from a left border to a top border on cards */
  .job-table tbody tr{ border-top: 3px solid var(--text-faint); }
  .row-status-amber{ border-top-color: var(--amber) !important; }
  .row-status-green{ border-top-color: var(--green) !important; }
  .row-status-red{ border-top-color: var(--red) !important; }

  /* first column renders as a card header, not a label/value row */
  .td-card-header{
    background: var(--panel-raised);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
  }
  .td-card-header::before{ display:none; }
  .td-card-header > *{ text-align:left; }

  .empty-state{ padding: 48px 16px; }

  /* ---- drawer → full-screen sheet ---- */
  .drawer-overlay{ align-items: stretch; }
  .drawer{
    width: 100%;
    border-left: none;
    animation: slideUp .2s ease;
  }
  @keyframes slideUp{ from{ transform: translateY(16px); opacity:0; } to{ transform: translateY(0); opacity:1; } }
  .drawer-foot{ flex-direction: column-reverse; gap: 10px; align-items: stretch; }
  .drawer-foot-right{ flex-direction: column-reverse; gap: 8px; }
  .drawer-foot-right button, #drawerDelete{ width: 100%; text-align:center; }

  .toast{ left: 14px; right: 14px; transform: none; bottom: 16px; text-align:center; }
}

/* =========================================================
   COURTESY CAR — FLEET GRID
   ========================================================= */
.fleet-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.fleet-card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--text-faint);
  border-radius: var(--radius);
  padding: 16px;
}
.fleet-card-in{ border-top-color: var(--green); }
.fleet-card-out{ border-top-color: var(--red); }
.fleet-card-top{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 8px;
}
.fleet-reg{
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.4px;
}
.fleet-reg-pending{ color: var(--amber); }
.fleet-card{ cursor: pointer; transition: border-color .15s ease; }
.fleet-card:hover{ border-color: var(--text-faint); }
.fleet-pending-note{
  font-size: 11.5px;
  color: var(--amber);
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}
.fleet-status-pill{
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 3px 9px;
  border-radius: 100px;
}
.fleet-status-pill.green{ background: rgba(92,200,160,0.15); color: var(--green); }
.fleet-status-pill.red{ background: rgba(224,101,79,0.15); color: var(--red); }
.fleet-model{
  font-size: 13.5px;
  font-weight: 500;
  margin: 0 0 4px;
}
.fleet-meta{ font-size: 12px; color: var(--text-dim); margin: 0; }
.fleet-loan-note{
  font-size: 12px;
  color: var(--amber);
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

.section-divider{
  margin: 36px 0 22px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.section-divider .workspace-title{ margin-top: 4px; }

/* Scrollbar */
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-thumb{ background: var(--border); border-radius:4px; }
::-webkit-scrollbar-track{ background: transparent; }
