/* reports.css
   ===========
   Zakladka Raporty: przelacznik zakresu (range-switch, wspoldzielony z
   raportem online paliwa), kreator raportu Excel typu drag&drop oraz
   tabela "raportu online" (wykryte tankowania/ubytki paliwa).
*/

  .range-switch {
    display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; gap: 2px; align-self: flex-start;
  }
  .range-switch button {
    border: none; background: none; color: var(--text-dim); font-family: inherit; font-size: 12px;
    font-weight: 600; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  }
  .range-switch button.active { background: var(--accent-brand); color: #14181D; }

  .report-online-fuel-controls.show { display: flex !important; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
  .report-online-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
  .report-online-table th, .report-online-table td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--border); }
  .report-online-table th { color: var(--text-dim); font-weight: 600; font-size: 11px; }
  .report-online-table td.mono, .report-online-table th.mono { font-family: var(--font-mono, 'IBM Plex Mono', ui-monospace, monospace); }
  .report-online-diff-pos { color: var(--accent-red); }
  .report-online-diff-neg { color: var(--accent-brand); }
  .report-online-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700; }
  .report-online-badge.tankowanie { background: rgba(107, 158, 104, 0.18); color: var(--accent-brand); }
  .report-online-badge.ubytek { background: rgba(242, 84, 91, 0.15); color: var(--accent-red); }
  /* --- Kreator raportu (drag&drop) --- */
  .report-builder-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
  }

  .report-dnd-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .report-dnd-col-title { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; font-weight: 600; }
  .report-dnd-zone {
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 8px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .report-dnd-zone-target.drag-over { border-color: var(--accent-brand); background: rgba(107, 158, 104, 0.08); }
  .report-dnd-empty { font-size: 11px; color: var(--text-dim); text-align: center; padding: 20px 4px; }

  .report-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    cursor: grab;
  }
  .report-chip:active { cursor: grabbing; opacity: 0.7; }
  .report-chip.dragging { opacity: 0.4; }
  .report-chip .report-chip-remove { color: var(--accent-red); font-weight: 700; cursor: pointer; flex-shrink: 0; }

  .report-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
  }

  .report-status { font-size: 12.5px; color: var(--text-dim); margin-top: 10px; min-height: 18px; }
  .report-status.error { color: var(--accent-red); }
  .report-status.success { color: var(--accent-green); }

  /* Asystent (agent AI) - nowy modul 25.07.2026 */
  .assistant-panel { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 400px; }
  .assistant-conv-tabs {
    display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; flex-shrink: 0; padding-bottom: 2px;
  }
  .assistant-conv-tab {
    display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px;
    background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--text-dim);
    cursor: pointer; white-space: nowrap; flex-shrink: 0;
  }
  .assistant-conv-tab.active { background: var(--accent-brand); color: #fff; border-color: var(--accent-brand); }
  .assistant-conv-tab .conv-tab-close { opacity: 0.6; font-size: 13px; line-height: 1; }
  .assistant-conv-tab .conv-tab-close:hover { opacity: 1; }
  .assistant-conv-tab-new {
    flex-shrink: 0; padding: 6px 12px; border-radius: 8px; background: transparent;
    border: 1px dashed var(--border); color: var(--text-dim); font-size: 12px; cursor: pointer;
  }
  .assistant-conv-tab-new:hover { border-color: var(--accent-brand); color: var(--accent-brand); }
  .assistant-messages {
    flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
    padding: 4px 2px; margin-bottom: 10px;
  }
  .assistant-msg {
    max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.5;
    white-space: pre-wrap;
  }
  .assistant-msg.user { align-self: flex-end; background: var(--accent-brand); color: #fff; border-bottom-right-radius: 3px; }
  .assistant-msg.assistant { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 3px; }
  .assistant-msg.assistant.loading { color: var(--text-dim); font-style: italic; }
  .assistant-msg.assistant.error { background: rgba(242, 84, 91, 0.12); color: var(--accent-red); }
  .assistant-input-row { display: flex; gap: 8px; align-items: stretch; }
  .assistant-input-row input {
    flex: 1 1 auto; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-family: inherit; font-size: 15px; outline: none;
  }
  .assistant-input-row input:focus { border-color: var(--accent-brand); }
  .assistant-input-row #assistant-send-btn {
    width: auto; flex: 0 0 auto; padding: 8px 16px; font-size: 13px; margin-top: 0; align-self: center;
  }

/* ===== Raport: Bezpieczenstwo ===== */
/* Dodane 27.08.2026 - alerty DMS/ADAS z kamer VisionMax. */

.safety-kpi-row { display: flex; gap: 12px; flex-wrap: wrap; }

.safety-kpi {
  flex: 1 1 130px;
  padding: 12px 14px;
  border: 1px solid var(--border, #d8dde3);
  border-radius: 10px;
  background: var(--surface, #fff);
  text-align: center;
}
.safety-kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.safety-kpi-label { font-size: 12px; color: var(--text-dim, #78838f); margin-top: 4px; }
.safety-kpi-note { font-size: 11px; opacity: .8; }

.safety-types { margin-top: 16px; }
.safety-types-title { font-size: 12px; color: var(--text-dim, #78838f); margin-bottom: 8px; }

.safety-type-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px; border-radius: 6px; cursor: pointer;
}
.safety-type-row:hover { background: var(--surface-2, rgba(0,0,0,.04)); }
.safety-type-name { flex: 0 0 200px; font-size: 13px; }
.safety-type-bar {
  flex: 1; height: 10px; border-radius: 5px;
  background: var(--surface-2, rgba(0,0,0,.08)); overflow: hidden;
}
.safety-type-bar > span { display: block; height: 100%; background: var(--accent, #2f6fd0); }
.safety-type-count { flex: 0 0 92px; text-align: right; font-size: 12px; }

.safety-filter-note { margin-bottom: 8px; font-size: 13px; }
.safety-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.safety-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.safety-sortable:hover { text-decoration: underline; }

.safety-media-ok { color: var(--ok, #2e7d32); }
/* Zdarzenie blisko konca retencji - material zaraz zniknie po stronie
   dostawcy i to jedyny moment, zeby go pobrac. */
.safety-media-warn { color: #b26a00; font-weight: 600; }
.safety-media-gone { color: var(--text-dim, #78838f); }

.safety-media-box {
  background: var(--surface, #fff); border-radius: 10px; overflow: hidden;
  width: min(920px, 94vw); max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.safety-media-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--border, #d8dde3); font-weight: 600; font-size: 14px;
}
.safety-media-body { overflow-y: auto; padding: 12px; }
.safety-media-item { margin-bottom: 14px; }
.safety-media-item video,
.safety-media-item img { width: 100%; border-radius: 8px; display: block; background: #000; }
.safety-media-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 6px; font-size: 12px; color: var(--text-dim, #78838f);
}
.safety-media-msg {
  padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.5;
  background: var(--surface-2, rgba(0,0,0,.04)); margin-bottom: 12px;
}
.safety-media-msg.blad { background: rgba(211,47,47,.1); }
.safety-media-msg.ostrzezenie { background: rgba(255,193,7,.14); }

@media (max-width: 640px) {
  .safety-type-name { flex-basis: 120px; }
  .safety-kpi-value { font-size: 20px; }
}

/* ===== Pola daty w raportach ===== */
/* Dodane 27.08.2026. Domyslny wyglad pola typu "date" mocno odstaje od
   reszty panelu, wiec ujednolicamy go z przyciskami .range-switch -
   to samo tlo, zaokraglenia i akcent marki. */

  .report-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
  }

  .report-row label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
  }

  .report-row input[type="date"],
  .report-row select {
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 7px 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, background .15s;
  }

  .report-row input[type="date"]:hover,
  .report-row select:hover { background: var(--surface); border-color: var(--border); }

  .report-row input[type="date"]:focus,
  .report-row select:focus {
    outline: none;
    border-color: var(--accent-brand);
    background: var(--surface);
  }

  /* Ikona kalendarza w domyslnym kolorze przegladarki bywa niewidoczna w
     motywie ciemnym - odwracamy ja razem z motywem. */
  .report-row input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .65;
  }
  .report-row input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

  [data-theme="dark"] .report-row input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
  }
