/* BAEG Timesheets Portal — follows the ba_project_portal "command center" theme */
:root {
  --ink: #333333;
  --ink-2: #2a3439;
  --muted: #666666;
  --line: #e7e5e4;
  --line-2: #d6d3d1;
  --surface: #ffffff;
  --nav: #222222;          /* BAEG dark nav bar */
  --accent: #f58020;       /* BAEG orange */
  --orange-dark: #cc6922;
  --accent-ink: #a8521a;

  /* status palette (dark variants, shared with the hub) */
  --ok-d: #2fd27a;   --warn-d: #f5b942;   --bad-d: #f5634a;
  --ok: #16a34a;    --ok-bg: #dcfce7;
  --warn: #f59e0b;  --warn-bg: #fef3c7;
  --bad: #dc2626;   --bad-bg: #fee2e2;

  --radius: 14px;
  --font: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --title-font: "Jura", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* dark dashboard surface — shared with the hub */
  --page-bg: #0d0f13;
  --glass: rgba(255,255,255,0.04);
  --glass-line: rgba(255,255,255,0.09);
  --txt: #e8ebf0;
  --txt-dim: #9aa3b2;

  color-scheme: dark; /* native date/time pickers render dark */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--txt);
  background: var(--page-bg);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}
/* faint ambient glow behind the whole page (matches the hub) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 500px at 88% 0%, rgba(60,120,220,0.07), transparent 55%),
    radial-gradient(1000px 520px at 5% 8%, rgba(245,128,32,0.06), transparent 55%);
}
body > * { position: relative; z-index: 1; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--title-font); margin: 0; }

/* ---- top info bar (BAEG) ---- */
#topbar {
  background: linear-gradient(180deg, #cc6922 0%, #f58020 100%);
  color: #fff;
  font-size: 11px;
  padding: 4px 20px;
  text-align: right;
  letter-spacing: 0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#topbar a { color: #fff; text-decoration: none; opacity: 0.9; }
#topbar a:hover { opacity: 1; }

/* ---- main header (dark nav bar, BAEG) ---- */
header.app-header {
  background: var(--nav);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; min-height: 64px; max-width: 900px; margin: 0 auto; width: 100%;
  gap: 12px; flex-wrap: wrap;
}
.logo-wrap { display: flex; align-items: center; gap: 14px; text-decoration: none; min-width: 0; }
.logo-wrap img { height: 38px; width: auto; display: block; }
.logo-badge {
  height: 36px; width: 36px; border-radius: 6px; background: var(--accent);
  color: #18181b; font-family: var(--title-font); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.page-title {
  font-family: var(--title-font);
  font-size: 14px; font-weight: 500; color: #fff;
  text-transform: uppercase; letter-spacing: 1px;
  border-left: 2px solid var(--accent); padding-left: 14px; opacity: 0.92;
  white-space: nowrap;
}
.header-right { display: flex; align-items: center; gap: 12px; color: #cbd2dd; font-size: 12px; }

.logout-btn {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); color: #e7e5e4;
  font: inherit; font-size: 11px; font-weight: 600; padding: 7px 14px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .5px;
}
.logout-btn:hover { background: rgba(255,255,255,.16); color: #fff; }

/* ---- layout ---- */
main.wrap {
  max-width: 900px; margin: 0 auto;
  padding: 24px 20px calc(60px + env(safe-area-inset-bottom));
}

/* section heading, matching the hub's subhead treatment */
.section-title {
  font-family: var(--title-font); font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--txt-dim); margin: 0 0 16px;
  display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--glass-line); }

/* ---- glass cards (hub style) ---- */
.card {
  position: relative; overflow: visible;
  background: var(--glass); border: 1px solid var(--glass-line);
  border-radius: var(--radius); padding: 20px 20px 18px;
  backdrop-filter: blur(6px);
  margin-bottom: 20px;
}
/* top accent line, same treatment as the hub's cards */
.card::after {
  content: ""; position: absolute; top: 0; left: 14px; right: 14px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: .5;
  pointer-events: none;
}

/* ---- form grids ---- */
.form-grid { display: grid; gap: 16px; }
.grid-details { grid-template-columns: 1fr 1fr; }
.grid-job { grid-template-columns: 150px minmax(0, 1fr) 220px; }
.grid-times { grid-template-columns: repeat(4, 1fr) 150px; align-items: end; }
.form-grid + .form-grid { margin-top: 16px; }

/* ---- fields ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--txt-dim);
}
.field input, .field select, .field textarea {
  font: inherit; font-size: 16px; /* ≥16px stops iOS zooming the page on focus */
  padding: 11px 12px; border: 1px solid var(--glass-line); border-radius: 10px;
  background: rgba(255,255,255,0.05); color: var(--txt); width: 100%; min-height: 46px;
}
.field select option { background: #16191f; color: var(--txt); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,128,32,0.18);
}
/* iOS Safari gives date/time inputs an intrinsic width that ignores width:100%,
   so they overflow the card and overlap neighbours — strip the native chrome
   and left-align the value like every other field */
.field input[type="date"], .field input[type="time"] {
  -webkit-appearance: none; appearance: none;
  display: block; min-width: 0; max-width: 100%;
  text-align: left;
}
.field input::-webkit-date-and-time-value { text-align: left; margin: 0; }
.field input[type="date"]::-webkit-calendar-picker-indicator,
.field input[type="time"]::-webkit-calendar-picker-indicator { opacity: 0.6; }
.field input:read-only { color: var(--txt-dim); background: rgba(255,255,255,0.03); }
.field .hint { font-size: 11px; color: var(--txt-dim); }
.override-label {
  font-weight: 400 !important; text-transform: none !important; letter-spacing: 0 !important;
  display: inline-flex !important; flex-direction: row !important; align-items: center;
  gap: 5px; margin-left: 8px; color: var(--txt-dim);
}
.override-label input[type="checkbox"] {
  -webkit-appearance: checkbox; appearance: auto;
  width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0;
  accent-color: var(--accent);
}
.entry-error { font-size: 13px; color: #ff8a76; min-height: 1.2em; margin-top: 12px; }
.entry-error:empty { display: none; }

/* ---- buttons ---- */
.btn {
  border: 1px solid var(--glass-line); background: rgba(255,255,255,0.06); color: var(--txt);
  padding: 11px 18px; border-radius: 10px; font: inherit; font-weight: 600; font-size: 14px;
  min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: rgba(255,255,255,0.12); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #18181b; font-weight: 700; }
.btn.primary:hover { background: var(--orange-dark); color: #fff; }
.btn.ghost { background: none; border-color: transparent; color: var(--txt-dim); }
.btn.ghost:hover { background: rgba(255,255,255,0.06); color: var(--txt); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---- job typeahead ---- */
.typeahead { position: relative; }
.typeahead-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: linear-gradient(180deg, #1a1d24 0%, #14171d 100%);
  border: 1px solid var(--glass-line); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55); max-height: 300px; overflow-y: auto;
}
.typeahead-group-label {
  font-family: var(--title-font);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--txt-dim); padding: 10px 14px 4px;
}
.typeahead-item { padding: 11px 14px; cursor: pointer; font-size: 14px; }
.typeahead-item:hover, .typeahead-item.active { background: rgba(245,128,32,0.14); }
.typeahead-item .job-id { font-weight: 700; color: var(--accent); margin-right: 8px; font-family: var(--mono); font-size: 13px; }
.typeahead-item .job-name { color: var(--txt); }
.typeahead-empty { padding: 14px; color: var(--txt-dim); font-size: 13px; }

/* ---- entries table (desktop) ---- */
.table-wrap {
  border: 1px solid var(--glass-line); border-radius: 12px; overflow: auto;
  background: rgba(0,0,0,0.15);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 11px 12px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--txt-dim); font-weight: 700; border-bottom: 1px solid var(--glass-line);
  background: rgba(255,255,255,0.03); white-space: nowrap;
}
tbody td { padding: 12px; border-bottom: 1px solid rgba(255,255,255,0.06); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
.entries-empty { padding: 26px; text-align: center; color: var(--txt-dim); }
.weekly-total {
  font-weight: 700; text-align: right; padding: 14px 4px 2px; font-size: 15px;
  font-family: var(--title-font); letter-spacing: .3px; color: #fff;
}

/* ---- weekly grid day cells ---- */
table.grid td.day-cell { padding: 8px; }
.grid-entry {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(245,128,32,0.12); border: 1px solid rgba(245,128,32,0.3);
  border-radius: 7px; padding: 4px 6px; font-size: 12px; margin: 2px 0;
}
.grid-entry + .grid-entry { margin-left: 5px; }
.grid-entry .grid-entry-hours { font-weight: 700; color: #ffd9b0; font-family: var(--mono); }
.grid-entry button {
  border: none; background: none; padding: 0 3px; font-size: 13px; line-height: 1; cursor: pointer;
  color: var(--txt-dim); min-height: unset;
}
.grid-entry button[data-action="delete"]:hover { color: #ff8a76; }
.grid-entry button[data-action="edit"]:hover { color: var(--accent); }
.grid-total-cell { font-weight: 700; color: #fff; font-family: var(--mono); }
.job-cell-label { display: block; margin-top: 3px; font-size: 11px; color: var(--txt-dim); line-height: 1.35; }

/* ---- entries list (mobile) ---- */
.entries-list { display: none; }
.day-group { margin-bottom: 18px; }
.day-group:last-child { margin-bottom: 0; }
.day-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-family: var(--title-font); font-size: 12px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--txt-dim); margin-bottom: 8px;
  padding-bottom: 6px; border-bottom: 1px solid var(--glass-line);
}
.day-total { font-family: var(--mono); font-size: 12px; color: var(--txt); letter-spacing: 0; }
.day-total.over { color: var(--warn-d); }
.entry-card {
  display: flex; align-items: stretch; justify-content: space-between; gap: 12px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--glass-line);
  border-radius: 12px; padding: 13px 14px; margin-bottom: 10px;
}
.entry-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.entry-job { font-size: 14px; color: var(--txt); line-height: 1.35; }
.entry-job strong { color: var(--accent); font-family: var(--mono); margin-right: 6px; }
.entry-meta { font-size: 12px; color: var(--txt-dim); }
.entry-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 8px; flex-shrink: 0; }
.entry-hours { font-family: var(--title-font); font-size: 17px; font-weight: 700; color: #ffd9b0; white-space: nowrap; }
.entry-actions { display: flex; gap: 6px; }
.entry-actions button {
  border: 1px solid var(--glass-line); background: rgba(255,255,255,0.05); color: var(--txt-dim);
  font: inherit; font-size: 11px; font-weight: 600; padding: 6px 11px; border-radius: 8px;
  min-height: 32px;
}
.entry-actions button[data-action="edit"]:hover { color: var(--accent); border-color: rgba(245,128,32,0.4); }
.entry-actions button[data-action="delete"]:hover { color: #ff8a76; border-color: rgba(245,99,74,0.4); }
.entries-list .entries-empty {
  border: 1px dashed var(--glass-line); border-radius: 12px;
}

/* ---- badges ---- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; border: 1px solid var(--glass-line); }
.badge.ok { background: rgba(47,210,122,0.12); border-color: rgba(47,210,122,0.32); color: #6ee7a8; }
.badge.warn { background: rgba(245,185,66,0.12); border-color: rgba(245,185,66,0.32); color: #f7cd72; }
.badge.bad { background: rgba(245,99,74,0.14); border-color: rgba(245,99,74,0.38); color: #ff8a76; }

/* ---- submit row ---- */
.submit-row { display: flex; justify-content: flex-end; }

/* ---- modal (hub dialog styling) ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: linear-gradient(180deg, #16191f 0%, #101216 100%); color: var(--txt);
  border: 1px solid var(--glass-line); border-top: 2px solid var(--accent);
  border-radius: var(--radius); max-width: 680px; width: 100%; max-height: 88vh; max-height: 88dvh;
  overflow-y: auto; padding: 24px; box-shadow: 0 24px 70px rgba(0,0,0,0.6);
}
.modal h2 { margin-bottom: 14px; font-size: 17px; font-weight: 700; color: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.modal.modal-sm { max-width: 440px; }
.modal.alert-error { border-top-color: var(--bad-d); }
.modal.alert-warn { border-top-color: var(--warn-d); }
.modal.alert-error h2 { color: #ff8a76; }
.modal.alert-warn h2 { color: #f7cd72; }
#alertMessage { margin: 0; color: var(--txt); line-height: 1.55; }
#reviewSummary p { margin: 0 0 8px; color: var(--txt); }

/* long-day flag banner in the review modal */
.review-warn {
  color: #f7cd72; font-weight: 600; margin: 10px 0 0 !important;
  background: rgba(245,185,66,0.1); border: 1px solid rgba(245,185,66,0.3);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5;
}

/* ---- toast ---- */
.toast {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: #22262e; color: #fff; border: 1px solid var(--glass-line);
  padding: 13px 18px; border-radius: 12px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 100; display: none;
  max-width: min(480px, calc(100vw - 32px)); text-align: center;
}
.toast.show { display: block; }
.toast.error { background: #3a1512; border-color: rgba(245,99,74,0.5); color: #ffb4a8; }
.toast.ok { background: #0f2b1c; border-color: rgba(47,210,122,0.45); color: #6ee7a8; }
.toast.warn { background: #33260d; border-color: rgba(245,185,66,0.45); color: #f7cd72; }

/* ---- footer ---- */
#footer {
  max-width: 900px; margin: 0 auto; padding: 0 20px calc(28px + env(safe-area-inset-bottom));
  color: var(--txt-dim); font-size: 12px; text-align: center;
}

/* ---- login page (matches the hub login) ---- */
.login-body {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(1100px 460px at 80% -10%, rgba(245,128,32,0.16), transparent 60%),
    linear-gradient(180deg, #1c1f26 0%, #111317 100%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 30px 30px 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4); border-top: 4px solid var(--accent);
  color-scheme: light;
}
.login-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.login-logo img { height: 40px; width: auto; display: block; }
.login-logo .logo-badge { height: 40px; width: 40px; font-size: 16px; }
.login-card h1 { font-size: 19px; margin: 18px 0 2px; color: var(--ink); letter-spacing: 0.3px; }
.login-card .login-sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.login-card input { font: inherit; font-size: 16px; padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--ink); }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,128,32,0.18); }
.login-card button { margin-top: 4px; background: var(--accent); color: #18181b; border: none; border-radius: 10px; padding: 13px; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; min-height: 48px; }
.login-card button:hover { background: var(--orange-dark); color: #fff; }
.login-card button:disabled { opacity: 0.7; cursor: default; }
.login-error { color: var(--bad); font-size: 13px; min-height: 1em; text-align: center; }

/* ============================================================
   Mobile — most crews submit from their phones
   ============================================================ */
@media (max-width: 700px) {
  .header-inner { padding: 8px 14px; min-height: 56px; }
  .logo-wrap img { height: 30px; }
  .page-title { font-size: 12px; padding-left: 10px; letter-spacing: .8px; }
  #whoami { display: none; } /* keep the top bar uncluttered on small screens */
  #topbar { padding: 4px 14px; text-align: center; }
  #topbar .topbar-extra { display: none; }

  main.wrap { padding: 18px 14px calc(48px + env(safe-area-inset-bottom)); }
  .card { padding: 16px 14px 15px; margin-bottom: 16px; }

  /* stack the form fields full-width for thumbs */
  .grid-details, .grid-job { grid-template-columns: 1fr; }
  .grid-times { grid-template-columns: 1fr 1fr; }
  .grid-times .field-submit { grid-column: 1 / -1; }
  .form-grid { gap: 14px; }

  /* swap the wide week grid for the stacked day list */
  .table-wrap.entries-table { display: none; }
  .entries-list { display: block; }
  .weekly-total { text-align: left; padding-top: 12px; }

  /* full-width primary action */
  .submit-row .btn { width: 100%; }

  /* bottom-sheet style modals */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 18px 18px 0 0; max-height: 92vh; max-height: 92dvh;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }

  .typeahead-results { max-height: 45vh; }
}
