/* ==========================================================================
   Timeline — sdílené styly
   Používá public/js/timeline.js. Zapojeno ve warehouse-v2.html (historie
   u produktu) a event-stream.html (globální stream událostí).

   Styly pro zasazení timeline do tabulky produktů (.btn-timeline-toggle,
   .timeline-row-td, .timeline-container) zůstávají ve warehouse-v2.html —
   stream stránka tabulku nemá.
   ========================================================================== */

/* ---- Hlavička & filtry ---- */
.tl-header {
    font-size: 0.72rem; font-weight: 600; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.04em;
    margin-bottom: 8px; padding-bottom: 6px;
    border-bottom: 1px solid #e5e7eb;
    display: flex; align-items: center; justify-content: space-between;
}
.tl-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tl-filter-chip {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.72rem; font-weight: 600; cursor: pointer;
    padding: 3px 9px; border-radius: 12px; user-select: none;
    border: 1px solid transparent; transition: all 0.15s;
}
.tl-filter-chip input[type="checkbox"] { display: none; }
.fc-orders { background: #e0f7fa; color: #0E7490; border-color: #b2ebf2; }
.fc-stock  { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.fc-prices { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.fc-badge  { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.fc-minstock { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
.fc-webhook { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
/* Ceny, dostupnost a "objednáno" mají v event-streamu vlastní kartu/tečku
   (tl-card-price/dot-price, tl-card-avail/dot-avail, tl-card-ordered/dot-ordered),
   proto i pilulka filtru barevně sedí přesně na ně - viz event-stream.html. */
.fc-price   { background: #fffbeb; color: #f59e0b; border-color: #fde68a; }
.fc-avail   { background: #f3f4f6; color: #9ca3af; border-color: #e5e7eb; }
.fc-ordered { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
.tl-filter-chip.fc-off { background: #f3f4f6 !important; color: #9ca3af !important; border-color: #e5e7eb !important; }
.tl-filter-chip.fc-disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- Scroll kontejner (jen vnořená varianta u produktu) ---- */
.tl-scroll { max-height: 320px; overflow-y: auto; padding-right: 4px; }

/* ---- Uzel timeline ---- */
.tl-node { display: flex; gap: 10px; }
.tl-spine { flex: 0 0 14px; display: flex; flex-direction: column; align-items: center; }
.tl-spine-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #9ca3af; border: 2px solid #f8f9fa;
    flex-shrink: 0; margin-top: 5px;
}
.dot-order  { background: #0E7490; }
.dot-stock  { background: #3b82f6; }
.dot-price  { background: #f59e0b; }
.dot-action { background: #8b5cf6; }
.dot-avail  { background: #9ca3af; }
.dot-ordered { background: #7c3aed; }
.dot-badge   { background: #16a34a; }
.dot-minstock { background: #db2777; }
.dot-webhook { background: #6366f1; }
.tl-spine-line { flex: 1; width: 2px; background: #e5e7eb; margin-top: 3px; min-height: 8px; }
.tl-node:last-child .tl-spine-line { background: transparent; }
.tl-node-body { flex: 1; min-width: 0; padding-bottom: 10px; }
.tl-node-time { font-size: 0.63rem; color: #9ca3af; margin-bottom: 4px; }

/* ---- Karty událostí ---- */
.tl-card {
    border-radius: 5px; border: 1px solid #e5e7eb; background: white;
    padding: 5px 8px; font-size: 0.78rem; max-width: 580px;
}
.tl-card + .tl-card { margin-top: 3px; }
.tl-card-order  { border-left: 3px solid #0E7490; }
.tl-card-stock  { border-left: 3px solid #3b82f6; }
.tl-card-stock-critical { border-left: 3px solid #dc3545; }
.tl-card-price  { border-left: 3px solid #f59e0b; }
.tl-card-action { border-left: 3px solid #8b5cf6; }
.tl-card-avail  { border-left: 3px solid #9ca3af; }
.tl-card-ordered { border-left: 3px solid #7c3aed; }
.tl-card-badge   { border-left: 3px solid #16a34a; }
.tl-card-minstock { border-left: 3px solid #db2777; }
.tl-card-webhook { border-left: 3px solid #6366f1; }
.tl-actor { font-weight: 400; color: #6b7280; font-size: 0.72rem; }

.tl-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tl-card-left { display: flex; align-items: baseline; gap: 6px; min-width: 0; flex: 1; }
.tl-card-icon { flex-shrink: 0; font-size: 0.82rem; line-height: 1.4; }
.tl-card-title { font-weight: 600; font-size: 0.77rem; color: #374151; }
.tl-card-sub { font-size: 0.73rem; color: #6b7280; margin-top: 2px; }

/* Seskupený cenový blok */
.tl-price-group { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 4px; }

/* Podskupiny burst karty pohybů skladu (Doskladnění / Vyskladnění) */
.tl-stock-subgroup-title {
    display: flex; align-items: center; gap: 4px;
    font-size: 0.62rem; font-weight: 700; color: #9ca3af;
    text-transform: uppercase; letter-spacing: 0.03em;
    margin: 6px 0 3px;
}
.tl-stock-subgroup-title:first-of-type { margin-top: 2px; }
.tl-price-lbl { font-size: 0.62rem; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.03em; display: block; margin-bottom: 1px; }
.tl-price-val { font-size: 0.75rem; }
/* Odkaz na objednávku & stavový štítek */
.tl-order-link { color: #0E7490; font-weight: 700; text-decoration: none; }
.tl-order-link:hover { text-decoration: underline; }
.tl-badge { font-size: 0.62rem; font-weight: 700; padding: 2px 7px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
.tl-badge-new        { background: #dbeafe; color: #1e40af; }
.tl-badge-processing { background: #fef3c7; color: #92400e; }
.tl-badge-done       { background: #d1fae5; color: #065f46; }
.tl-badge-cancel     { background: #fee2e2; color: #991b1b; }
.tl-badge-default    { background: #f3f4f6; color: #374151; }
.tl-badge-action-on  { background: #ede9fe; color: #5b21b6; }
.tl-badge-action-off { background: #f3f4f6; color: #6b7280; }
/* product:*, category:*, brand:* and supplier:* webhook sync detail (SyncResult.action, viz syncDetailHtml() v timeline.js) */
.tl-badge-sync-created { background: #dbeafe; color: #1e40af; }
.tl-badge-sync-updated { background: #ede9fe; color: #5b21b6; }
.tl-badge-sync-hidden  { background: #fee2e2; color: #991b1b; }
.tl-badge-sync-skipped { background: #f3f4f6; color: #6b7280; }
/* Raw Shoptet field(s) that changed but aren't tracked/synced - diagnostic only, shown next to tl-badge-sync-skipped */
.tl-badge-sync-untracked { background: #fef3c7; color: #92400e; }

.tl-up   { color: #059669; font-weight: 600; }
.tl-down { color: #dc3545; font-weight: 600; }
.tl-old  { color: #9ca3af; }
.tl-diff { font-size: 0.68rem; color: #9ca3af; margin-left: 2px; }

/* ==========================================================================
   Režim showProduct — jen globální stream
   ========================================================================== */

/* Hlavička karty s produktem */
.tl-product {
    display: flex; align-items: center; gap: 7px;
    margin: -1px 0 5px; padding-bottom: 4px;
    border-bottom: 1px dashed #e5e7eb;
}
.tl-product-img {
    width: 28px; height: 28px; flex-shrink: 0;
    object-fit: contain; background: #f9fafb;
    border: 1px solid #e5e7eb; border-radius: 3px;
}
.tl-product-img-empty {
    display: flex; align-items: center; justify-content: center;
    color: #d1d5db; font-size: 0.8rem;
}
.tl-product-name {
    font-size: 0.75rem; font-weight: 600; color: #1f2937;
    text-decoration: none; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.tl-product-name:hover { color: #0E7490; text-decoration: underline; }
.tl-product-brand {
    font-size: 0.75rem; font-weight: 600; color: #6b7280;
    flex-shrink: 0; white-space: nowrap;
}
.tl-product-code {
    font-size: 0.65rem; color: #9ca3af; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    flex-shrink: 0; margin-left: auto; text-decoration: none;
}
a.tl-product-code:hover { color: #0E7490; text-decoration: underline; }

/* Rozbalitelné položky objednávky */
.tl-items-toggle {
    display: inline-flex; align-items: center; gap: 5px;
    margin-top: 4px; padding: 2px 0;
    font-size: 0.72rem; font-weight: 600; color: #0E7490;
    background: none; border: none; cursor: pointer;
}
.tl-items-toggle:hover { text-decoration: underline; }
.tl-items-chevron { display: inline-block; transition: transform 0.18s ease; font-size: 0.65rem; }
.tl-items-toggle.expanded .tl-items-chevron { transform: rotate(90deg); }
.tl-items { display: none; margin-top: 5px; border-top: 1px dashed #e5e7eb; padding-top: 5px; }
.tl-items.expanded { display: block; }
.tl-item {
    display: flex; align-items: center; gap: 7px;
    padding: 3px 0; font-size: 0.73rem;
}
.tl-item + .tl-item { border-top: 1px solid #f3f4f6; }
.tl-item-img {
    width: 24px; height: 24px; flex-shrink: 0;
    object-fit: contain; background: #f9fafb;
    border: 1px solid #e5e7eb; border-radius: 3px;
}
.tl-item-name {
    flex: 1; min-width: 0; color: #374151; text-decoration: none;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.tl-item-name:hover { color: #0E7490; text-decoration: underline; }
.tl-item-brand { font-weight: 600; color: #6b7280; flex-shrink: 0; }
.tl-item-qty { color: #6b7280; flex-shrink: 0; }
.tl-item-total { font-weight: 600; color: #1f2937; flex-shrink: 0; }

/* Neproduktové řádky (doprava, platba, sleva…) – decentnější */
.tl-item-nonproduct { color: #6b7280; }
.tl-item-icon {
    display: flex; align-items: center; justify-content: center;
    color: #9ca3af; font-size: 0.8rem;
}
.tl-item-aux { color: #6b7280; }
.tl-item-type { color: #9ca3af; font-size: 0.68rem; }

/* ==========================================================================
   Vstupní animace nových uzlů (auto-refresh)
   ========================================================================== */

/* Obal nově vložených uzlů — rozbalí se z nulové výšky, čímž stávající
   obsah plynule sjede dolů. Konkrétní max-height nastavuje JS podle
   skutečné výšky obsahu; po dokončení se obal rozpustí. */
.tl-incoming {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.tl-incoming .tl-node {
    opacity: 0;
    transform: translateY(-8px);
    animation: tlNodeIn 0.35s ease forwards;
}
@keyframes tlNodeIn {
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .tl-incoming { transition: none; }
    .tl-incoming .tl-node { animation: none; opacity: 1; transform: none; }
    .tl-items-chevron { transition: none; }
}
