/* ── los_blank.css — LOS blank form styles ─────────────────────────────────── */

/* ── Wrapper ───────────────────────────────────────────────────────────────── */
.lb-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 40px 24px;
  color: var(--muted);
  font-size: 14px;
}

.lb-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Toolbar ────────────────────────────────────────────────────────────────── */
.lb-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.lb-title {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Main layout ────────────────────────────────────────────────────────────── */
.lb-main {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
}

.lb-form {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 32px;
  min-width: 0;
}

/* ── Grid of blocks ─────────────────────────────────────────────────────────── */
.lb-blocks-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto;
  gap: 14px;
  grid-template-areas:
    "client    client    object"
    "supply    drain     obstacles"
    "casing    pour      extras"
    "station   station   station"
    "documents documents documents";
}

/* Assign grid areas */
.lb-block[data-group="client"]    { grid-area: client; }
.lb-block[data-group="object"]    { grid-area: object; }
.lb-block[data-group="obstacles"] { grid-area: obstacles; }
.lb-block[data-group="supply"]    { grid-area: supply; }
.lb-block[data-group="drain"]     { grid-area: drain; }
.lb-block[data-group="casing"]    { grid-area: casing; }
.lb-block[data-group="pour"]      { grid-area: pour; }
.lb-block[data-group="extras"]    { grid-area: extras; }
.lb-block[data-group="station"]   { grid-area: station; }
.lb-block[data-group="documents"] { grid-area: documents; }

/* ── Block component ─────────────────────────────────────────────────────────── */
.lb-block {
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

.lb-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-weight: 600;
  font-size: 13px;
  gap: 8px;
}

.lb-block-header::-webkit-details-marker { display: none; }

.lb-block-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s;
  opacity: 0.6;
}

.lb-block[open] .lb-block-chevron {
  transform: rotate(180deg);
}

.lb-block-body {
  padding: 12px 14px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

/* Wide blocks have more room for fields */
.lb-block[data-group="client"] .lb-block-body,
.lb-block[data-group="station"] .lb-block-body {
  grid-template-columns: repeat(3, 1fr);
}

.lb-block[data-group="extras"] .lb-block-body {
  grid-template-columns: 1fr 1fr;
}

/* Textarea should span full width */
.lb-field:has(.lb-textarea) {
  grid-column: 1 / -1;
}

/* Checkbox fields */
.lb-field-checkbox {
  display: flex;
  align-items: center;
}

.lb-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.lb-checkbox {
  width: 17px !important;
  height: 17px !important;
  min-width: 17px;
  cursor: pointer;
  accent-color: var(--accent);
  padding: 0 !important;
  border-radius: 3px;
}

.lb-checkbox-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

/* Obstacles block: 3-column checklist grid */
.lb-block[data-group="obstacles"] .lb-block-body {
  grid-template-columns: repeat(3, 1fr);
}

/* Tractor type dropdown sits right after the traktor checkbox — span inline */
.lb-block[data-group="obstacles"] .lb-field:not(.lb-field-checkbox) {
  grid-column: auto;
}

/* ── Colour themes for blocks ────────────────────────────────────────────────── */
.lb-block-white   { --lb-header-bg: #f5f5f5;   --lb-body-bg: #ffffff;   --lb-border: #e0e0e0; }
.lb-block-green   { --lb-header-bg: #c8e6c9;   --lb-body-bg: #e8f5e9;   --lb-border: #a5d6a7; }
.lb-block-red     { --lb-header-bg: #ffcdd2;   --lb-body-bg: #ffebee;   --lb-border: #ef9a9a; }
.lb-block-blue    { --lb-header-bg: #bbdefb;   --lb-body-bg: #e3f2fd;   --lb-border: #90caf9; }
.lb-block-beige   { --lb-header-bg: #f5e6b8;   --lb-body-bg: #faf3e0;   --lb-border: #f0d9a0; }
.lb-block-pink    { --lb-header-bg: #f8bbd0;   --lb-body-bg: #fce4ec;   --lb-border: #f48fb1; }
.lb-block-cyan    { --lb-header-bg: #b2ebf2;   --lb-body-bg: #e0f7fa;   --lb-border: #80deea; }
.lb-block-gray    { --lb-header-bg: #eeeeee;   --lb-body-bg: #f5f5f5;   --lb-border: #bdbdbd; }
.lb-block-yellow  { --lb-header-bg: #fff9c4;   --lb-body-bg: #fffde7;   --lb-border: #fff176; }

.lb-block {
  border-color: var(--lb-border, var(--border));
  background: var(--lb-body-bg, var(--surface));
}

.lb-block-header {
  background: var(--lb-header-bg, var(--surface));
  border-bottom: 1px solid var(--lb-border, var(--border));
}

/* Dark mode overrides — soften colours */
[data-theme="dark"] .lb-block-white   { --lb-header-bg: #333;     --lb-body-bg: #2a2825;   --lb-border: #444; }
[data-theme="dark"] .lb-block-green   { --lb-header-bg: #1a3a22;  --lb-body-bg: #162e1c;   --lb-border: #2d6a3a; }
[data-theme="dark"] .lb-block-red     { --lb-header-bg: #4a1a1a;  --lb-body-bg: #3a1212;   --lb-border: #8b2020; }
[data-theme="dark"] .lb-block-blue    { --lb-header-bg: #0d2a45;  --lb-body-bg: #0a1e33;   --lb-border: #1565a0; }
[data-theme="dark"] .lb-block-beige   { --lb-header-bg: #3a2f10;  --lb-body-bg: #2d2408;   --lb-border: #6b5520; }
[data-theme="dark"] .lb-block-pink    { --lb-header-bg: #4a1530;  --lb-body-bg: #3a0d22;   --lb-border: #9c2655; }
[data-theme="dark"] .lb-block-cyan    { --lb-header-bg: #0a3038;  --lb-body-bg: #082228;   --lb-border: #0e6070; }
[data-theme="dark"] .lb-block-gray    { --lb-header-bg: #2a2a2a;  --lb-body-bg: #222222;   --lb-border: #444; }
[data-theme="dark"] .lb-block-yellow  { --lb-header-bg: #3a3000;  --lb-body-bg: #2c2400;   --lb-border: #6b5f00; }

/* ── Field ────────────────────────────────────────────────────────────────────── */
.lb-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-req {
  color: var(--danger, #e53935);
  margin-left: 2px;
}

.lb-hint {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
}

.lb-input {
  font-size: 13px;
  padding: 7px 10px;
}

.lb-textarea {
  resize: vertical;
  min-height: 70px;
  font-size: 13px;
}

.lb-input-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.lb-input-unit .lb-input {
  flex: 1;
  padding-right: 36px;
}

.lb-unit {
  position: absolute;
  right: 10px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}

.lb-station-select {
  width: 100%;
}

/* ── Preview panel ────────────────────────────────────────────────────────────── */
.lb-preview {
  width: 300px;
  min-width: 240px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

.lb-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.lb-preview-header i {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.lb-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 13px;
}

.lb-preview-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-top: 32px;
}

.lb-preview-summary {
  margin-bottom: 14px;
}

.lb-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.lb-preview-total {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  border-bottom-width: 2px;
}

.lb-preview-disc { color: var(--muted); }

.lb-preview-margin {
  color: var(--success, #2e7d32);
  font-size: 12px;
}

.lb-preview-rows-label {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.lb-preview-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.lb-preview-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border);
  align-items: baseline;
}

.lb-preview-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.lb-preview-item-qty {
  color: var(--muted);
  white-space: nowrap;
}

.lb-preview-item-price {
  white-space: nowrap;
  font-weight: 600;
}

.lb-preview-more {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px 0;
}

.lb-preview-warnings {
  margin-top: 10px;
}

.lb-preview-warn {
  font-size: 11px;
  color: var(--warning, #e65100);
  padding: 2px 0;
}

/* ── Block warnings ──────────────────────────────────────────────────────────── */
.lb-block-warning {
  background: #fff3cd;
  color: #7d4e00;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-bottom: 1px solid #f0c040;
  letter-spacing: 0.2px;
}

[data-theme="dark"] .lb-block-warning {
  background: #4a3200;
  color: #ffd86e;
  border-bottom-color: #7a5800;
}

/* Inline station warning — sits right below the station picker */
.lb-station-warning {
  grid-column: 1 / -1;
  background: #fff3cd;
  color: #7d4e00;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #f0c040;
  margin-top: 2px;
}

[data-theme="dark"] .lb-station-warning {
  background: #4a3200;
  color: #ffd86e;
  border-color: #7a5800;
}

/* ── Toast notifications ──────────────────────────────────────────────────────── */
.lb-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

.lb-toast.lb-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.lb-toast.lb-toast-error {
  background: var(--danger, #e53935);
}

.lb-toast.lb-toast-warn {
  background: #e65100;
}

/* ── Templates list ────────────────────────────────────────────────────────────── */
.templates-list-header {
  padding: 24px 24px 4px;
}

.templates-list-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.templates-list-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
}

.templates-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 0 24px 32px;
}

.template-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
  min-width: 280px;
  max-width: 420px;
  flex: 1;
  position: relative;
}

.template-card:hover {
  border-color: var(--card-accent, var(--accent));
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

.template-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 15%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.template-card-icon i {
  width: 22px;
  height: 22px;
  color: var(--card-accent, var(--accent));
}

.template-card-body {
  flex: 1;
  min-width: 0;
}

.template-card-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 3px;
}

.template-card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.template-card-arrow {
  color: var(--muted);
  flex-shrink: 0;
}

.template-card-arrow i {
  width: 18px;
  height: 18px;
}

/* ── Responsive breakpoints ────────────────────────────────────────────────────── */

/* 2 columns: 700–1099px */
@media (max-width: 1099px) {
  .lb-blocks-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "client    object"
      "supply    drain"
      "obstacles casing"
      "pour      extras"
      "station   station"
      "documents documents";
  }
}

/* 1 column: <700px — stack everything, collapse blocks */
@media (max-width: 699px) {
  .lb-main {
    flex-direction: column;
  }

  .lb-preview {
    width: 100%;
    min-width: unset;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 280px;
  }

  .lb-blocks-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "client"
      "object"
      "obstacles"
      "supply"
      "drain"
      "casing"
      "pour"
      "extras"
      "station"
      "documents";
  }

  /* Collapse non-critical blocks on mobile */
  .lb-block[data-group="casing"],
  .lb-block[data-group="pour"],
  .lb-block[data-group="extras"] {
    /* keep collapsed by default on mobile — user can open */
  }

  .lb-block[data-group="casing"]:not([open]),
  .lb-block[data-group="pour"]:not([open]),
  .lb-block[data-group="extras"]:not([open]) {
    /* intentionally left closed by default */
  }

  .lb-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .lb-title {
    width: 100%;
    order: -1;
  }
}

@media (max-width: 480px) {
  .lb-block-body {
    grid-template-columns: 1fr;
  }
}

/* ── Input wrapper (for amo indicator + lock icon) ──────────────────────────── */
.lb-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lb-input-wrap .form-control {
  flex: 1;
  min-width: 0;
}

/* ── AMO synced badge ────────────────────────────────────────────────────────── */
.lb-amo-synced {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  color: #7b1fa2;
  background: #f3e5f5;
  border: 1px solid #ce93d8;
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

/* ── Readonly AMO field ───────────────────────────────────────────────────────── */
.lb-readonly-amo {
  background: #f5f5f5 !important;
  color: var(--muted, #666) !important;
  cursor: not-allowed;
  border-color: #ddd !important;
}

.lb-lock-icon {
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0.6;
  user-select: none;
}

/* ── Conflict banner ─────────────────────────────────────────────────────────── */
.lb-conflict-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  background: #fff8e1;
  border-bottom: 2px solid #ffca28;
  color: #5d4037;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.lb-conflict-resolve-btn {
  margin-left: 4px;
  background: #ff8f00;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.lb-conflict-resolve-btn:hover { background: #e65100; }

.lb-conflict-dismiss-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #8d6e63;
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.lb-conflict-dismiss-btn:hover { color: #5d4037; }

/* ── Conflict modal ──────────────────────────────────────────────────────────── */
.lb-conflict-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lb-conflict-modal {
  background: var(--surface, #fff);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
  max-width: 700px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lb-cm-header {
  padding: 16px 20px 12px;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--border, #e0e0e0);
  color: var(--text, #222);
}

.lb-cm-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.lb-cm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.lb-cm-table th {
  text-align: left;
  padding: 7px 10px;
  font-weight: 600;
  color: var(--muted, #666);
  border-bottom: 2px solid var(--border, #e0e0e0);
  white-space: nowrap;
}

.lb-cm-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border, #e0e0e0);
  vertical-align: middle;
}

.lb-cm-field { font-weight: 500; min-width: 120px; }
.lb-cm-blank { color: #1565c0; }
.lb-cm-amo   { color: #6a1b9a; }

.lb-cm-choice {
  display: flex;
  gap: 12px;
  white-space: nowrap;
}

.lb-cm-radio {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.lb-cm-radio input { cursor: pointer; }

.lb-cm-footer {
  display: flex;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border, #e0e0e0);
  justify-content: flex-end;
}

/* ── Purple block (Documents) ────────────────────────────────────────────────── */
.lb-block-purple .lb-block-header {
  background: #e1bee7;
  border-bottom: 1px solid #ce93d8;
  color: #2a0a3a;
}

.lb-block-purple {
  background: #f3e5f5;
  border-color: #ce93d8;
}
