/* OPS//HUB application stylesheet — uses tokens from tokens.css.
 *
 * Component vocabulary follows OPSHUB_design_tokens_v2.md. This file
 * keeps a baseline; richer component styles get added as screens land.
 */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

/* ------------------------------------------------------------------
 * App shell — fixed left sidebar + main content area.
 *
 * Layout shape mirrors the V1 prototype (lines 56–146 + 1283–1342).
 * Styling here is simplified vs the prototype: text-only nav links,
 * URL-prefix-driven active state, no SVG icons yet. Polish (icons,
 * active-state animation, mobile collapse) ships in a follow-up PR.
 * ------------------------------------------------------------------ */

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.app-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.app-sidebar-brand {
  padding: 24px 20px; /* prototype line 68 */
  border-bottom: 1px solid var(--border);
}

.app-sidebar-brand .brand-mark {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.05em;
  color: var(--accent);
  line-height: 1;
}

.app-sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: var(--space-1);
}

.app-sidebar-nav {
  /* prototype line 89: padding 16px 12px, gap 2px between buttons */
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  /* prototype line 97: 9px, letter-spacing 3px, padding 12px 8px 6px */
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.nav-link {
  /* prototype line 105: padding 10px 12px, mono font, 12px, weight 700,
     letter-spacing 0.3px. Active state reserves a 1px transparent border
     so the layout doesn't shift when active. */
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  text-decoration: none;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-link.active {
  /* Vertex-Orange-tinted active state — same shape as the prototype's
     yellow-lime active, recolored to our brand per design tokens v2. */
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.nav-link.disabled {
  color: var(--text-light);
  cursor: not-allowed;
  opacity: 0.55;
}

.nav-link.disabled:hover {
  background: transparent;
  color: var(--text-light);
}

.app-sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.app-sidebar-footer .user-info-email {
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

.app-sidebar-footer .user-info-role {
  display: inline-block;
  align-self: flex-start;
  padding: 2px var(--space-2);
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-sidebar-footer .sign-out {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--space-1) 0;
}

.app-sidebar-footer .sign-out:hover {
  color: var(--danger);
}

/* "● System Online" status (prototype line 1339 — `.sidebar-footer` +
   `.status-dot`). Static dot for v1; pulse animation lands with polish. */
.sidebar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-2);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.app-main {
  /* Fills the 1fr grid track edge-to-edge. Inner padding lives on
     `.app-content`, not on `<main>` itself. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.app-content {
  flex: 1;
  padding: 32px; /* prototype line 209 */
}

/* ------------------------------------------------------------------
 * Page layout — anonymous (login) case (no shell, plain <main>)
 * ------------------------------------------------------------------ */

.anon-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-5);
}

/* Two-tone page title per design doc — leading word in `text`,
   trailing word in `accent` (Vertex Orange). Apply via two spans. */
.page-title {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 var(--space-5);
  color: var(--text);
}

.page-title .accent {
  color: var(--accent);
}

.app-footer {
  text-align: center;
  padding: var(--space-5);
  color: var(--text-muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------
 * Dashboard tile grid layout
 *
 * Tile visuals (.kpi-tile and friends) live in components.css.
 * This rule only sets the grid that arranges tile macros.
 * ------------------------------------------------------------------ */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

/* ------------------------------------------------------------------
 * Login card
 * ------------------------------------------------------------------ */

.login-card {
  max-width: 420px;
  margin: 6rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-card h1 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 var(--space-3);
  color: var(--accent);
  letter-spacing: 0.05em;
}

.login-card .lede {
  color: var(--text-muted);
  margin-bottom: var(--space-5);
}

.dev-note {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-size: 12px;
  margin: var(--space-4) 0;
  text-align: left;
}

/* Buttons (per design doc §Buttons; only Primary defined for now) */
.btn-primary {
  display: inline-block;
  padding: var(--space-3) var(--space-5);
  background: var(--primary);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  height: 36px;
}

.btn-primary:hover {
  background: var(--vertex-cyan);
}

.muted {
  color: var(--text-muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------
 * Work Order screens — shared layout primitives.
 *
 * BWC, CMT, and Marrero share the same card-grid skeleton (per V1
 * prototype). Field colors come from the existing `.field-input`
 * (yellow) and `.field-conv` (pink) rules in components.css.
 * ------------------------------------------------------------------ */

.wo-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}

.wo-screen-actions {
  display: flex;
  gap: var(--space-2);
}

.wo-card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.wo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.wo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.wo-card-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wo-card-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.wo-card-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

.wo-card-footer {
  margin-top: var(--space-3);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.wo-banner-closed {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  color: var(--warning);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-weight: 600;
  font-size: 12px;
}

/* Fieldset wraps the form's input cards so a Closed WO renders read-only
   via the `disabled` attribute. Strip the default browser chrome so it's
   structurally invisible. */
.wo-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.wo-astm-badge {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 1px 6px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------
 * Search Work Orders modal — native <dialog>.
 *
 * Dimensions copied literally from the V1 prototype lines 7174-7191
 * (per `feedback_measure_prototype_for_visuals.md`).
 * ------------------------------------------------------------------ */

.wo-search-modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 680px;
  width: calc(100% - 48px);
}

.wo-search-modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.wo-search-modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.wo-search-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.wo-search-modal-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.wo-search-modal-close {
  background: var(--danger);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-body);
}

.wo-search-modal-body {
  padding: 20px 24px;
}

.wo-search-form {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.wo-search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
}

.wo-search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.wo-search-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 400px;
  overflow-y: auto;
}

.wo-search-empty {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: var(--space-5);
}

.wo-search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.wo-search-result-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.wo-search-result-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.wo-search-result-number {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
}

.wo-search-result-bwc { color: var(--success); }
.wo-search-result-cmt { color: var(--info); }
.wo-search-result-mar { color: var(--danger); }

.wo-search-result-detail {
  display: flex;
  gap: var(--space-4);
  color: var(--text-muted);
  font-size: 11px;
}

.wo-search-result-open {
  white-space: nowrap;
  font-size: 11px;
  padding: 6px 14px;
  text-decoration: none;
}

.wo-search-result-pending {
  font-size: 10px;
  color: var(--text-light);
  font-style: italic;
  white-space: nowrap;
  padding: 6px 14px;
}

/* ------------------------------------------------------------------
 * Saved-orders log table at the bottom of the WO form.
 *
 * Mirrors the V1 prototype's `.data-table` (lines 343-378) recolored
 * to our brand tokens.
 * ------------------------------------------------------------------ */

.wo-orders-log {
  margin-bottom: var(--space-4);
}

.wo-orders-log-table {
  width: 100%;
  border-collapse: collapse;
}

.wo-orders-log-table th {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.wo-orders-log-table td {
  padding: 12px 16px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.wo-orders-log-table tr:hover td {
  background: var(--surface-alt);
}

.wo-orders-log-table tr:last-child td {
  border-bottom: none;
}

.wo-orders-log-link {
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
  text-decoration: none;
}

.wo-orders-log-link:hover {
  text-decoration: underline;
}

.wo-orders-log-total {
  color: var(--success);
  font-weight: 600;
}

.wo-orders-log-empty {
  text-align: center;
  padding: var(--space-5);
  color: var(--text-muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------
 * Attachments list (BWC form, above the field cards).
 *
 * Maps to V1 prototype lines 1642-1645 (autofill banner area; the
 * attachments live similarly inside the form). Restyled to use our
 * tokens; per-row UI keeps the prototype's icon + name + size + remove.
 * ------------------------------------------------------------------ */

.wo-attachments {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.wo-attachments-label {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.wo-attachments-list {
  /* container; styled by children */
}

.wo-attachments-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.wo-attachments-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.wo-attachment-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.wo-attachment-icon {
  flex-shrink: 0;
}

.wo-attachment-name {
  flex: 1;
  color: var(--primary);
  text-decoration: none;
  font-family: var(--font-mono);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wo-attachment-name:hover {
  text-decoration: underline;
}

.wo-attachment-size {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.wo-attachment-remove {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px 8px;
  font-size: 12px;
}

.wo-attachment-remove:hover {
  background: var(--danger);
  color: var(--text-inverse);
  border-color: var(--danger);
}

.wo-attach-label {
  cursor: pointer;
}
