/* Phillips Electrical - Job Scheduler
   Design tokens (matched to phillipselectrical.com.au):
   --ink        #0C1024  brand navy-black, base background
   --panel      #161B33  raised surface (cards, sidebar)
   --panel-line #262C4A  hairline borders on dark surfaces
   --paper      #F2F3F8  off-white, text on dark surfaces
   --muted      #8B90AD  secondary text
   --blue       #4D5BFF  signature accent - brand lightning-bolt blue
   --blue-2     #7C6CFF  secondary gradient stop (bolt gradient)
   --live       #3FB68B  in-progress / circuit-live green
   --alert      #E5484D  overdue / fault red
   Type:
   display/utility: 'JetBrains Mono' - job numbers, times, amounts, breaker labels
   body/UI: 'Inter' - everything else
*/

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;700&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #0C1024;
  --panel: #161B33;
  --panel-line: #262C4A;
  --paper: #F2F3F8;
  --muted: #8B90AD;
  --amber: #4D5BFF;      /* kept variable name for compatibility - now the brand blue */
  --amber-dim: #1D2350;
  --blue: #4D5BFF;
  --blue-2: #7C6CFF;
  --live: #3FB68B;
  --alert: #E5484D;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

a { color: inherit; }

/* ---------- App shell ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--panel-line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: block;
  text-decoration: none;
  padding: 4px 6px 14px;
}
.brand-logo-full { width: 100%; max-width: 168px; height: auto; display: block; }
.brand-logo-icon { display: none; width: 34px; height: 34px; border-radius: 8px; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a svg { width: 19px; height: 19px; flex-shrink: 0; }

.nav a:hover {
  background: rgba(245, 166, 35, 0.06);
  color: var(--paper);
}

.nav a.active {
  color: var(--paper);
  background: rgba(245, 166, 35, 0.1);
  border-left-color: var(--amber);
}

.main {
  padding: 28px 32px 60px;
  max-width: 1100px;
  min-width: 0;
}

/* ---------- Tablet / iPad portrait: icon rail, no labels ---------- */
@media (max-width: 900px) and (min-width: 641px) {
  .app-shell { grid-template-columns: 74px 1fr; }
  .sidebar { padding: 16px 10px; align-items: center; }
  .brand { padding: 0 0 12px; }
  .brand-logo-full { display: none; }
  .brand-logo-icon { display: block; margin: 0 auto; }
  .nav a { justify-content: center; padding: 12px; }
  .nav-label { display: none; }
  .main { padding: 24px 20px 60px; }
}

/* ---------- Mobile: bottom tab bar ---------- */
@media (max-width: 640px) {
  .app-shell {
    grid-template-columns: 1fr;
    display: block;
  }
  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 40;
    flex-direction: row;
    align-items: stretch;
    padding: 6px 4px;
    border-right: none;
    border-top: 1px solid var(--panel-line);
    overflow-x: auto;
    gap: 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
  }
  .brand { display: none; }
  .nav { flex-direction: row; gap: 0; width: 100%; justify-content: space-between; }
  .nav a {
    flex-direction: column;
    flex: 1 1 0;
    min-width: 0;
    gap: 2px;
    padding: 8px 2px;
    border-left: none;
    border-radius: 8px;
    font-size: 9px;
    text-align: center;
  }
  .nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .nav a.active { border-left: none; background: rgba(245,166,35,0.14); }
  .nav a svg { width: 19px; height: 19px; }
  .main { padding: 20px 16px 88px; }
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.page-header .today {
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  font-size: 13px;
}

.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
  color: #FFFFFF;
}
.btn-primary:hover { filter: brightness(1.1); }

.btn-ghost {
  background: transparent;
  border-color: var(--panel-line);
  color: var(--paper);
}
.btn-ghost:hover { border-color: var(--muted); }

/* ---------- Layout: schedule + jobs panel ---------- */

.layout-split {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 860px) {
  .layout-split { grid-template-columns: 1fr; }
}

/* ---------- Schedule ---------- */

.day-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.day-chip {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
  cursor: pointer;
  min-width: 58px;
}
.day-chip .dow {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.day-chip .num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 16px;
  margin-top: 2px;
}
.day-chip.selected {
  border-color: var(--amber);
  background: rgba(245, 166, 35, 0.08);
}
.day-chip.selected .num { color: var(--amber); }
.day-chip .dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--live);
  margin: 4px auto 0;
}

.modal-backdrop form label {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  font-weight: 500;
}

.modal-backdrop form input:not([type="checkbox"]):not([type="radio"]),
.modal-backdrop form select,
.modal-backdrop form textarea {
  background: var(--ink);
  border: 1px solid var(--panel-line);
  color: var(--paper);
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  width: 100%;
  box-sizing: border-box;
}

.modal-backdrop form input:focus,
.modal-backdrop form select:focus,
.modal-backdrop form textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.modal-backdrop form input[type="checkbox"] {
  width: auto;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
}
.card .line-item-table { min-width: 480px; }

.event-list { display: flex; flex-direction: column; gap: 10px; }

.event-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--panel-line);
}
.event-row:last-child { border-bottom: none; }

.event-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.event-title { font-weight: 600; font-size: 14.5px; }
.event-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

.empty-state {
  padding: 32px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.empty-state strong {
  display: block;
  color: var(--paper);
  font-size: 14.5px;
  margin-bottom: 6px;
}

/* ---------- Breaker-switch job status (signature element) ---------- */

.panel-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

.breaker-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.breaker {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
}

.switch {
  position: relative;
  width: 26px;
  height: 42px;
  background: #0B0D0F;
  border-radius: 4px;
  border: 1px solid var(--panel-line);
}
.switch::after {
  content: '';
  position: absolute;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: var(--muted);
  transition: top 0.2s ease, background 0.2s ease;
}

/* states: quoted (off/top), scheduled (mid), in-progress (mid, live),
   done (on/bottom) */
.switch.state-quoted::after     { top: 3px;  background: var(--muted); }
.switch.state-scheduled::after  { top: 11px; background: var(--amber); }
.switch.state-progress::after   { top: 11px; background: var(--live); box-shadow: 0 0 8px rgba(63,182,139,0.7); }
.switch.state-done::after       { top: 20px; background: var(--live); }
.switch.state-overdue::after    { top: 11px; background: var(--alert); box-shadow: 0 0 8px rgba(229,72,77,0.7); }

.breaker-label { font-size: 13.5px; font-weight: 600; }
.breaker-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.status-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 4px;
}
.status-tag.quoted    { color: var(--muted); background: rgba(138,144,153,0.12); }
.status-tag.scheduled { color: var(--amber); background: rgba(245,166,35,0.12); }
.status-tag.progress  { color: var(--live);  background: rgba(63,182,139,0.12); }
.status-tag.done      { color: var(--live);  background: rgba(63,182,139,0.12); }
.status-tag.overdue   { color: var(--alert); background: rgba(229,72,77,0.12); }
