/*
 * Leppetrahvi kviitung — taastab vana süsteemi visuaalse struktuuri
 * (views/fines/view.php: .fine-paper, .fine-layout, .fine-left, .fine-right,
 * .fine-left-table, .fine-right-table).
 *
 * DISAINIOTSUS: kviitung jääb "paberiks" ka tumedas režiimis — valge taust,
 * must tekst, hallid jooned. See on juriidilise dokumendi koopia ja peab
 * välja nägema nagu väljaprinditud trahv, mitte nagu UI element.
 * Vt docs/decisions.md O-13.
 */

.parkit-fine-paper {
    background: #fff;
    color: #111;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 20px;
    /* Kviitung on fikseeritud laiusega dokument. Kitsal ekraanil ei suru me
       seda kokku (siis muutuks tabel loetamatuks), vaid laseme kerida. */
    overflow-x: auto;
}

.parkit-fine-paper * {
    color: inherit;
}

.parkit-fine-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
}

.parkit-fine-org {
    margin-top: 4px;
    font-size: 10px;
    color: #4b5563;
}

.parkit-fine-layout {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    align-items: flex-start;
    /* Alla selle laiuse hakkab kviitung kerima, mitte kokku surduma —
       muidu muutuvad 10px tabelid loetamatuks ja veerud kattuvad. */
    min-width: 680px;
}

.parkit-fine-left {
    flex: 1;
    min-width: 0;
}

.parkit-fine-right {
    width: 260px;
    flex: 0 0 260px;
}

.parkit-fine-left-table,
.parkit-fine-right-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    margin-bottom: 8px;
    /* fixed: ilma selleta venitavad pikad väärtused (nt kliendi aadress)
       tabeli konteinerist laiemaks ja lahtrid jooksevad kõrvaloleva
       maksekorralduse tabeli peale. */
    table-layout: fixed;
}

.parkit-fine-left-table td,
.parkit-fine-right-table td {
    border: 1px solid #e5e7eb;
    padding: 4px 6px;
    vertical-align: top;
    /* Pikk katkematu sõna (nt viitenumber) ei tohi lahtrist välja ulatuda. */
    overflow-wrap: anywhere;
}

/* Asjaolude lühikirjeldus — täislaiuses, veidi suurem kiri. */
.parkit-fine-reason td {
    font-size: 11px;
    line-height: 1.4;
}

.parkit-fine-left-table .label,
.parkit-fine-right-table .label {
    color: #6b7280;
    display: block;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.parkit-fine-right-table {
    font-size: 11px;
}

/* Maksekorralduse päis — vanas oli see hall tsentreeritud rida. */
.parkit-fine-right-table tr:first-child td {
    background: #f3f4f6;
    font-weight: bold;
    text-align: center;
}

.parkit-fine-sum td {
    font-size: 12px;
    font-weight: 700;
}

.parkit-fine-conditions {
    font-size: 10px;
    line-height: 1.5;
    text-align: justify;
    color: #374151;
    /* Tingimuste tekst on pikk (juriidiline plokk). Anname sellele oma
       kerimisala, et see ei venitaks lehte lõputult pikaks. */
    max-height: 220px;
    overflow-y: auto;
    padding-right: 6px;
    border-top: 1px solid #e5e7eb;
    padding-top: 8px;
    margin-top: 8px;
}

/* Kitsal ekraanil kaks veergu üksteise alla. */
@media (max-width: 900px) {
    .parkit-fine-layout {
        flex-direction: column;
        min-width: 0;
    }

    .parkit-fine-right {
        width: 100%;
        flex: 1 1 auto;
    }
}

/* ===== Pildigalerii ===== */

.parkit-image-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

@media (min-width: 640px) {
    .parkit-image-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
    .parkit-image-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1536px) {
    .parkit-image-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.parkit-thumb {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}

.dark .parkit-thumb {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.parkit-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.parkit-thumb:hover img {
    transform: scale(1.04);
}

/* Ajatempel pildi peal — loetav ka heleda foto peal tänu gradiendile. */
.parkit-thumb-stamp {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    padding: 10px 6px 4px;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: #fff;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
    pointer-events: none;
}

/* ===========================================================================
   Komponendid kohandatud vaadetele.

   TÄHTIS: Filamenti avaldatud app.css EI SISALDA Tailwindi utility-klasse
   (h-4, text-xs, rounded-lg jne) — ainult tema enda `fi-*` klasse. Vite
   build'i siin serveris ei ole (node/npm puudub). Seetõttu peavad kõik
   kohandatud Blade-vaadete stiilid olema SIIN, mitte utility-klassidena.

   Sümptom, mis selle välja tõi: <svg class="h-4 w-4"> ilma reaalse
   laiuspiiranguta renderdus terve konteineri suurusena.
   =========================================================================== */

.parkit-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.parkit-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.dark .parkit-section-title { color: #f9fafb; }

.parkit-count {
    font-size: 13px;
    font-weight: 400;
    color: #6b7280;
}

.dark .parkit-count { color: #9ca3af; }

.parkit-muted {
    font-size: 13px;
    color: #6b7280;
}

.dark .parkit-muted { color: #9ca3af; }

/*
 * Õiguste viga failide juures. EI OLE sama mis "faile ei ole" —
 * see on MEIE viga, mitte puuduvad andmed, ja peab ka visuaalselt
 * erinema. Vt docs/decisions.md O-60.
 */
.parkit-error {
    font-size: 13px;
    color: #b45309;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 10px 12px;
}

.dark .parkit-error {
    color: #fcd34d;
    background: #2a2113;
    border-color: #78500a;
}

.parkit-stack > * + * { margin-top: 24px; }

/* --- Nupp --- */

.parkit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    color: #374151;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.parkit-btn:hover { background: #f9fafb; }

.dark .parkit-btn {
    color: #e5e7eb;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.dark .parkit-btn:hover { background: rgba(255, 255, 255, 0.1); }

/*
 * Ikooni suurus on siin fikseeritud KOLMES kohas korraga (width, height,
 * flex-shrink), sest SVG-l ilma selleta ei ole sisemist suurust ja ta
 * venib konteineri suuruseks.
 */
.parkit-btn-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    display: block;
}

/* --- Dokumentide tabel --- */

.parkit-doc-table-wrap {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.dark .parkit-doc-table-wrap { border-color: rgba(255, 255, 255, 0.1); }

.parkit-doc-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 13px;
}

.parkit-doc-table th {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
    color: #6b7280;
    background: #f9fafb;
}

.dark .parkit-doc-table th {
    color: #9ca3af;
    background: rgba(255, 255, 255, 0.05);
}

.parkit-doc-table td {
    padding: 8px 12px;
    height: 40px;
    border-top: 1px solid #e5e7eb;
    color: #111827;
}

.dark .parkit-doc-table td {
    border-top-color: rgba(255, 255, 255, 0.1);
    color: #f3f4f6;
}

.parkit-doc-table .col-size { width: 90px; text-align: right; }
.parkit-doc-table .col-actions { width: 150px; text-align: right; white-space: nowrap; }

.parkit-doc-name {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.parkit-doc-size {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: #6b7280;
}

.dark .parkit-doc-size { color: #9ca3af; }

.parkit-link {
    font-size: 12px;
    font-weight: 500;
    color: #2563eb;
    text-decoration: none;
}

.parkit-link:hover { text-decoration: underline; }

.dark .parkit-link { color: #60a5fa; }

.parkit-sep {
    margin: 0 6px;
    color: #d1d5db;
}

.dark .parkit-sep { color: #4b5563; }

/* ===========================================================================
   GLightboxi allkirja ("caption") parandused.

   Teegi vaikestiil on:
     .gslide-description { background: #fff }
     .gslide-desc        { color: #a1a1a1 }
     .gdesc-inner        { padding: 22px 20px }

   Hele hall valgel annab kontrasti ~2.3:1 — tekst on olemas, aga
   praktiliselt nähtamatu, mistõttu plokk paistab tühja valge kastina.
   Ja tühja sisuga jääb 44px polster ikka alles.

   Lahendus: tume läbipaistev riba heleda tekstiga (sobib lightboxi tumeda
   tagaplaaniga) + plokk peidetakse, kui sisu ei ole.
   =========================================================================== */

.glightbox-container .gslide-description {
    background: rgba(17, 17, 17, 0.92);
    border-radius: 0 0 6px 6px;
}

.glightbox-container .gdesc-inner {
    padding: 10px 14px;
}

/* Failinimi. */
.glightbox-container .gslide-title {
    color: #f9fafb;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    margin-bottom: 2px;
    line-height: 1.4;
}

/* Ajatempel ja suurus. */
.glightbox-container .gslide-desc {
    color: #d1d5db;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}

/*
 * Kui pealkirja ega kirjeldust ei ole (nt failil puudub ajatempel), ei tohi
 * jääda tühja riba. :has() katab juhu, kus mõlemad alamelemendid on tühjad.
 */
.glightbox-container .gslide-description:not(:has(.gslide-title:not(:empty))):not(:has(.gslide-desc:not(:empty))) {
    display: none;
}

/* Varuvariant vanematele brauseritele, kus :has() ei tööta. */
.glightbox-container .gdesc-inner:empty {
    display: none;
}
