/* ============================================================
   VLM – Shared Styles  (TV-optimised, dark theme)
   ============================================================ */

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #242836;
  --border:    #2e3345;
  --accent:    #3b82f6;
  --accent-dim:#1e3a5f;
  --green:     #22c55e;
  --yellow:    #eab308;
  --red:       #ef4444;
  --text:      #e8eaed;
  --text-dim:  #8b92a5;
  --highlight: #facc15;
  --radius:    10px;
}

html { font-size: 18px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- TV header ---------- */
.header {
  background: linear-gradient(135deg, #1e40af, #1e3a8a);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: .5px;
}
.header .subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,.7);
}
.header .clock {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  user-select: none;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background-color .15s, color .15s;
}
.header .clock:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.header .clock:active {
  background: rgba(255,255,255,.15);
}

/* ---------- Tray grid ---------- */
.tray-grid {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
}
.tray-grid.go-grid   { grid-template-columns: repeat(4, 1fr); }
.tray-grid.part-grid  { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

/* ---------- Tray card ---------- */
.tray-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .3s, border-color .3s;
}
.tray-card.highlight {
  border-color: var(--highlight);
  box-shadow: 0 0 20px rgba(250,204,21,.35);
}
.tray-card .tray-header {
  background: var(--surface2);
  padding: .6rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.tray-card .tray-header .tray-num {
  color: var(--accent);
}
.tray-card .tray-body {
  padding: .75rem 1rem;
  max-height: 300px;
  overflow-y: auto;
}
/* Scrollbar styling for tray body */
.tray-card .tray-body::-webkit-scrollbar { width: 6px; }
.tray-card .tray-body::-webkit-scrollbar-track { background: var(--surface); }
.tray-card .tray-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tray-card .tray-body::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* -- G.O. card specifics -- */
.go-card .tray-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  max-height: none;       /* G.O. cards don't need scroll */
  overflow-y: visible;
}
.go-card .go-number {
  font-size: 3rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1.1;
}
.go-card .go-number.empty {
  font-size: 1.5rem;
  color: var(--text-dim);
  font-weight: 400;
}
.go-card .go-desc {
  margin-top: .5rem;
  color: var(--text-dim);
  font-size: 1rem;
}

/* -- Parts card specifics -- */
.parts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.parts-table th {
  text-align: left;
  padding: .35rem .5rem;
  color: var(--text-dim);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.parts-table td {
  padding: .35rem .5rem;
  border-bottom: 1px solid var(--border);
}
.parts-table tr:last-child td { border-bottom: none; }
.parts-table tr.highlight-row td {
  background: rgba(250,204,21,.12);
  color: var(--highlight);
  font-weight: 600;
}
.empty-tray {
  color: var(--text-dim);
  font-style: italic;
  padding: .5rem 0;
  font-size: .9rem;
}

/* ---------- Search bar ---------- */
.search-bar {
  padding: 1rem 1.5rem;
  display: flex;
  gap: .75rem;
  align-items: center;
}
.search-bar input {
  flex: 1;
  max-width: 500px;
  padding: .65rem 1rem;
  font-size: 1.1rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar input::placeholder { color: var(--text-dim); }
.search-bar .search-info {
  color: var(--text-dim);
  font-size: .95rem;
}
.search-bar .search-info strong {
  color: var(--highlight);
}

/* ---------- Admin page ---------- */
.admin-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}
.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.admin-section-header {
  background: var(--surface2);
  padding: .75rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-section-body { padding: 1rem; }

/* Forms */
.form-row {
  display: flex;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}
.form-group { display: flex; flex-direction: column; gap: .25rem; }
.form-group label {
  font-size: .8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
}
.form-group input, .form-group select, .form-group textarea {
  padding: .5rem .65rem;
  font-size: .95rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--accent);
}

/* Buttons */
.btn {
  padding: .5rem 1rem;
  font-size: .9rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-danger    { background: var(--red);    color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

/* Admin table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.admin-table th {
  text-align: left;
  padding: .5rem;
  color: var(--text-dim);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: .45rem .5rem;
  border-bottom: 1px solid var(--border);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .actions { display: flex; gap: .4rem; }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
}
.tab {
  padding: .6rem 1.25rem;
  font-size: .95rem;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Notification toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--green);
  color: #000;
  padding: .6rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: .95rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s, transform .3s;
  z-index: 999;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Session / inactivity timer bar (admin + audit) ---------- */
.session-bar {
  background: var(--surface2);
  padding: .35rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.session-bar .timer { font-variant-numeric: tabular-nums; }
.session-bar .timer.warning { color: var(--yellow); font-weight: 600; }
.session-bar .timer.critical { color: var(--red); font-weight: 600; }

/* ---------- Custom right-click menu (text fields only) ---------- */
.app-ctx-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .25rem;
  min-width: 150px;
  box-shadow: 0 8px 24px rgba(0,0,0,.55);
  z-index: 1500;
  font-size: .9rem;
  color: var(--text);
  user-select: none;
}
.app-ctx-item {
  padding: .4rem .75rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}
.app-ctx-item:hover:not(.disabled) { background: var(--surface2); }
.app-ctx-item.disabled { color: var(--text-dim); cursor: default; }
.app-ctx-item .ctx-shortcut { color: var(--text-dim); font-size: .8rem; }

/* ---------- App dialogs (replaces browser alert/confirm/prompt) ---------- */
.app-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: appDialogFade .15s ease-out;
}
@keyframes appDialogFade { from { opacity: 0; } to { opacity: 1; } }
.app-dialog-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  min-width: 340px;
  max-width: min(560px, 92vw);
  box-shadow: 0 14px 50px rgba(0,0,0,.6);
}
.app-dialog-title {
  margin: 0 0 .65rem 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}
.app-dialog-title.danger { color: var(--red); }
.app-dialog-msg {
  font-size: .95rem;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
}
.app-dialog-input {
  margin-top: .85rem;
  width: 100%;
  padding: .55rem .75rem;
  font-size: 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.app-dialog-input:focus { border-color: var(--accent); }
.app-dialog-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

/* ---------- Responsive (smaller screens / admin) ---------- */
@media (max-width: 900px) {
  .tray-grid.go-grid { grid-template-columns: repeat(2, 1fr); }
  html { font-size: 16px; }
}
