/* public/css/style.css */

/* Best practice: gör så att width:100% inkluderar padding/border */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    padding: 24px;
    background: linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.5)), url('/images/background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.box {
    max-width: 420px;
    margin: 40px auto;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 10px;
}

label {
    display: block;
    margin-top: 12px;
}

/* Form controls: håll inputs/selects inom kortet och konsekventa */
input,
select,
textarea {
    width: 100%;
    padding: 10px;
    margin-top: 6px;
}

    /* Endast år-dropdownen ska vara kompakt */
    select.year-select {
        width: auto;
        min-width: 8ch; /* räcker för "Okänd" / 2052 */
    }
    /* År-dropdown: gör den snygg och matcha formspråket */
    select.year-select {
        width: auto;
        min-width: 10ch; /* lite mer luft än 8ch */
        padding: 10px 38px 10px 12px; /* plats för pilen */
        border-radius: 12px;
        border: 1px solid rgba(0,0,0,0.18);
        background-color: rgba(255, 255, 255, 0.85);
        box-shadow: 0 1px 2px rgba(0,0,0,0.08);
        appearance: none;
        -webkit-appearance: none;
        cursor: pointer;
        /* Enhetlig font med resten */
        font: inherit;
    }

    /* Lägg till en egen “pil” så den inte ser default/olika ut per browser */
    select.year-select {
        background-image: linear-gradient(45deg, transparent 50%, rgba(0,0,0,0.55) 50%), linear-gradient(135deg, rgba(0,0,0,0.55) 50%, transparent 50%), linear-gradient(to right, transparent, transparent);
        background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%, 0 0;
        background-size: 6px 6px, 6px 6px, 100% 100%;
        background-repeat: no-repeat;
    }

        select.year-select:focus-visible {
            outline: none;
            box-shadow: 0 0 0 3px rgba(91,156,255,0.35), 0 1px 2px rgba(0,0,0,0.08);
        }
/* Bananas buttons */
button,
a.btn-link {
    margin-top: 16px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #1a1a1a;
    background: linear-gradient(180deg, #ffffff 0%, #f3f3f3 100%);
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 999px; /* pill-form */
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15), 0 8px 20px rgba(0,0,0,0.12);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease, filter 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    text-decoration: none; /* viktigt för <a> */
}

    /* Hover */
    button:hover,
    a.btn-link:hover {
        transform: translateY(-1px);
        filter: brightness(1.03);
        box-shadow: 0 4px 8px rgba(0,0,0,0.18), 0 14px 28px rgba(0,0,0,0.16);
    }

    /* Active */
    button:active,
    a.btn-link:active {
        transform: translateY(1px);
        box-shadow: 0 2px 4px rgba(0,0,0,0.18);
    }

    /* Focus */
    button:focus-visible,
    a.btn-link:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px rgba(91,156,255,0.35), 0 8px 20px rgba(0,0,0,0.15);
    }

    /* Approve (grön) – gäller bara riktiga buttons */
    button.approve {
        color: #0b5d1e;
        background: linear-gradient(180deg, #e8fff0, #c9f5d8);
        border-color: #8dd9a8;
    }

        button.approve:hover {
            background: linear-gradient(180deg, #f0fff6, #bff0d0);
        }

    /* Danger (röd) */
    button.danger {
        color: #7a0b0b;
        background: linear-gradient(180deg, #ffecec, #ffd2d2);
        border-color: #f0a0a0;
    }

        button.danger:hover {
            background: linear-gradient(180deg, #fff2f2, #ffc4c4);
        }

    /* Secondary (neutral) */
    button.secondary {
        color: #1a1a1a;
        background: linear-gradient(180deg, #ffffff 0%, #f3f3f3 100%);
        border-color: rgba(0,0,0,0.15);
    }


.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.card {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(4px);
}
/* ===============================
   Approve-after-edit prompt
   =============================== */

.prompt-card h2 {
    margin-top: 0;
}

.prompt-subtitle {
    margin-top: 6px;
    opacity: 0.9;
}

.prompt-text {
    margin-top: 10px;
    line-height: 1.35;
}

.prompt-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* Extra för CRUD-tabellen */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

    .table th,
    .table td {
        border: 1px solid #ddd;
        padding: 10px;
        vertical-align: top;
        text-align: left;
    }

.actions {
    white-space: normal;
}

.inline {
    display: inline;
    margin-left: 6px;
}

.msg {
    color: #0a0;
    margin-top: 12px;
}

.hint {
    opacity: 0.8;
    margin-top: 10px;
}

.error {
    color: #c00;
}
/* ===============================
   Toasts (återanvänd)
   =============================== */

.toast-container-fixed {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
}

.toast {
    background-color: #ffffff;
    color: #111827;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    font-size: 0.875rem;
    max-width: 20rem;
    margin-top: 0.5rem;
    border: 1px solid #e5e7eb;
    transition: opacity 200ms ease, transform 200ms ease;
    opacity: 1;
    transform: translateY(0);
}

.toast--hide {
    opacity: 0;
    transform: translateY(4px);
}

.toast--success {
    background-color: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
}

.toast--error {
    background-color: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

/* === Form controls: modern "glass" look === */
input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 12px 12px;
    border-radius: 12px;
    /* soft border + subtle glass */
    border: 1px solid rgba(0, 0, 0, 0.18);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(8px);
    /* modern feel */
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    font: inherit;
    color: #111;
}

    input::placeholder,
    textarea::placeholder {
        color: rgba(0,0,0,0.45);
    }

    /* Focus state that matches your “premium” style */
    input[type="text"]:focus-visible,
    input[type="number"]:focus-visible,
    input[type="password"]:focus-visible,
    select:focus-visible,
    textarea:focus-visible {
        outline: none;
        border-color: rgba(91,156,255,0.55);
        box-shadow: 0 0 0 3px rgba(91,156,255,0.28), 0 1px 2px rgba(0,0,0,0.08);
    }

/* Optional: slightly reduce height on very small screens */
@media (max-width: 520px) {
    input[type="text"],
    input[type="number"],
    input[type="password"],
    select,
    textarea {
        padding: 10px 10px;
        border-radius: 10px;
    }
}
/* ===============================
   Status badges (pending/approved/started/done/archived)
   =============================== */

.status-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    border: 1px solid rgba(0,0,0,0.15);
    background: rgba(255,255,255,0.8);
}

.status-pending {
    color: #7a5a00;
    background: linear-gradient(180deg, #fff7e6, #ffe9bf);
    border-color: #f0d28a;
}

.status-approved {
    color: #0b5d1e;
    background: linear-gradient(180deg, #e8fff0, #c9f5d8);
    border-color: #8dd9a8;
}

.status-started {
    color: #0b3a6a;
    background: linear-gradient(180deg, #e8f3ff, #cfe6ff);
    border-color: #94c2ff;
}

.status-done {
    color: #0b5d1e;
    background: linear-gradient(180deg, #f0fff6, #d7f7e5);
    border-color: #8dd9a8;
}

.status-archived {
    color: #3a3a3a;
    background: linear-gradient(180deg, #f3f3f3, #e6e6e6);
    border-color: rgba(0,0,0,0.18);
}

/* --- Archive link in top bar --- */
.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-link {
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.15);
}

    .btn-link:hover {
        border-color: rgba(255,255,255,0.30);
    }

/* ===============================
   Modal (Edit proposal dialog)
   =============================== */

dialog.modal {
    border: 0;
    padding: 0;
    width: min(640px, calc(100vw - 32px));
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    box-shadow: 0 14px 40px rgba(0,0,0,0.30);
}

    /* Fix: centering in some browsers */
    dialog.modal[open] {
        margin: auto;
    }

    dialog.modal::backdrop {
        background: rgba(0,0,0,0.45);
    }

.modal-form {
    padding: 16px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.modal-title {
    margin: 0;
}

.modal-close {
    margin-top: 0; /* override global button margin-top */
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 999px;
    line-height: 1;
    font-size: 22px;
}

.modal-body label:first-child {
    margin-top: 0;
}

.modal-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* optional: a slightly more "neutral" look for cancel */
.btn-secondary {
    /* match your button base but a bit flatter */
    background: linear-gradient(180deg, #ffffff 0%, #f3f3f3 100%);
    border: 1px solid rgba(0,0,0,0.15);
}

/* ===============================
   Comments (proposal comments)
   =============================== */

.comments-row td {
    background: rgba(255, 255, 255, 0.35);
}

.comments {
    padding: 10px 6px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.comment {
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 10px;
    background: rgba(255,255,255,0.85);
}

.comment-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 6px;
}

.comment-date {
    opacity: 0.7;
}

.comment-updated {
    font-style: italic;
    opacity: 0.6;
}

.comment-text {
    white-space: pre-wrap;
    line-height: 1.4;
}

.comment-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
}

.comment-form textarea {
    resize: vertical;
}

.comment-edit-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}
/* Comments toggle (hidden by default) */
.comments-row.is-hidden {
    display: none;
}

/* ===============================
   Pagination
   =============================== */

.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 14px;
}

.pagination__page,
.pagination__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px; /* pill, matchar övriga UI */
    border: 1px solid rgba(0,0,0,0.15);
    background: linear-gradient(180deg, #ffffff 0%, #f3f3f3 100%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
    text-decoration: none;
    color: #1a1a1a;
    font-weight: 700;
    font-size: 14px;
}

    .pagination__page:hover,
    .pagination__nav:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.16);
    }

.pagination__current {
    background: rgba(255,255,255,0.85);
    border-color: rgba(0,0,0,0.25);
    box-shadow: 0 0 0 3px rgba(91,156,255,0.20), 0 2px 4px rgba(0,0,0,0.12);
}

.pagination__disabled {
    opacity: 0.55;
    cursor: default;
    transform: none !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.10);
}

.pagination__ellipsis {
    padding: 0 4px;
    opacity: 0.75;
    font-weight: 700;
}

/* ===============================
   Home: Title row (h2 + add button)
   =============================== */

.card-title-row {
    display: flex;
    align-items: center;
    gap: 10px; /* motsvarar "Förslag ␣ [knapp]" */
}

    .card-title-row h2 {
        margin: 0; /* så rubriken inte “puttar” layouten */
    }

    .card-title-row button {
        margin-top: 0; /* override global button margin-top */
    }

/* På smala skärmar: låt den wrappa snyggt */
@media (max-width: 520px) {
    .card-title-row {
        flex-wrap: wrap;
        gap: 10px;
    }

        .card-title-row button {
            width: 100%;
        }
}
/* ===============================
   Actions menu (⚙️ dropdown)
   =============================== */

.actions-menu {
    display: inline-block;
    position: relative; /* dropdownen positioneras härifrån */
}

.actions-gear {
    margin-top: 0; /* override global button margin-top */
    padding: 8px 12px;
    min-width: 44px; /* touch-vänligt */
}

/* Dropdown container */
.actions-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 50;
    min-width: 200px;
    padding: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0,0,0,0.12);
    box-shadow: 0 10px 28px rgba(0,0,0,0.20);
}

    /* Hidden state */
    .actions-dropdown.is-hidden {
        display: none;
    }

/* Forms inside dropdown should not add spacing weirdness */
.actions-menu-form {
    margin: 0;
}

/* Menu items (buttons) */
.actions-menu-item {
    width: 100%;
    margin-top: 0; /* override global button margin-top */
    padding: 10px 12px;
    text-align: left;
    display: block;
    border-radius: 12px;
}

    /* A little separation between items */
    .actions-menu-item + .actions-menu-item,
    .actions-menu-form + .actions-menu-form,
    .actions-menu-form + .actions-menu-item,
    .actions-menu-item + .actions-menu-form {
        margin-top: 6px;
    }

/* On very small screens, avoid dropdown going off-screen */
@media (max-width: 520px) {
    .actions-dropdown {
        right: 0;
        left: auto;
        min-width: 220px;
    }
}


/* ===============================
   Proposal details modal (Home + Archive)
   - Overlay modal (div), not <dialog>
   =============================== */

html.modal-open,
body.modal-open {
    overflow: hidden;
}

/* Root overlay */
#proposal-details-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
}

    /* Hidden state (we toggle is-hidden in JS) */
    #proposal-details-modal.is-hidden {
        display: none;
    }

    #proposal-details-modal .modal-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,0.45);
    }

    /* Card */
    #proposal-details-modal .modal-card {
        position: relative;
        width: min(720px, calc(100vw - 32px));
        margin: 8vh auto 0 auto;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(10px);
        box-shadow: 0 14px 40px rgba(0,0,0,0.30);
        border: 1px solid rgba(0,0,0,0.12);
        max-height: calc(100vh - 16vh);
        overflow: auto;
    }

    /* Reuse your existing .modal-header / .modal-close styling.
   This just ensures padding looks right for this modal too. */
    #proposal-details-modal .modal-header {
        padding: 14px 16px;
        border-bottom: 1px solid rgba(0,0,0,0.10);
    }

    #proposal-details-modal .modal-body {
        padding: 14px 16px 16px 16px;
    }

/* Make the "Vad" cell look like a link-button without breaking layout */
.proposal-details-trigger {
    margin-top: 0; /* override global button margin-top */
    padding: 0; /* keep table compact */
    background: transparent;
    border: 0;
    box-shadow: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

    .proposal-details-trigger:hover {
        filter: brightness(0.98);
    }

    .proposal-details-trigger:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px rgba(91,156,255,0.28);
        border-radius: 8px;
    }

/* Details layout inside modal */
.details-heading {
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 12px;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.details-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 12px;
    background: rgba(255,255,255,0.85);
}

.details-label {
    font-weight: 800;
    opacity: 0.85;
}

.details-value {
    opacity: 0.95;
}

/* Mobile: make it a bottom-sheet style */
@media (max-width: 520px) {
    #proposal-details-modal .modal-card {
        width: calc(100vw - 16px);
        margin: 0 auto;
        border-radius: 16px 16px 0 0;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        bottom: 0;
        top: auto;
        max-height: 82vh;
    }

    .details-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
/* ===============================
   Mobile polish: compact table + card-like rows
   Goal: make Home/Archive tables feel native on small screens
   =============================== */
@media (max-width: 520px) {

    /* Make the card breathe a bit less on tiny screens */
    body {
        padding: 14px;
    }

    .card {
        padding: 12px;
    }

    /* Turn the table into a "spaced rows" layout */
    .table {
        border-collapse: separate;
        border-spacing: 0 10px; /* vertical gaps between rows */
        margin-top: 10px;
    }

        /* Remove the heavy grid look */
        .table th,
        .table td {
            border: 0;
            padding: 10px 10px;
            background: rgba(255, 255, 255, 0.45);
        }

        /* Keep headers subtle and readable */
        .table thead th {
            background: transparent;
            padding: 6px 10px;
            font-size: 12px;
            opacity: 0.85;
        }

        /* Row "card" feel: round corners on first/last cells */
        .table tbody tr td:first-child {
            border-radius: 12px 0 0 12px;
        }

        .table tbody tr td:last-child {
            border-radius: 0 12px 12px 0;
        }

    /* Comments row: keep it visually connected */
    .comments-row td {
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.35);
        padding: 10px 10px;
    }

    /* Tighten the actions column so the gear feels "in-row" */
    td.actions {
        padding-left: 6px;
        padding-right: 6px;
        width: 1%;
        white-space: nowrap;
        vertical-align: middle;
    }

    .actions-menu {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .actions-gear {
        padding: 7px 10px;
        min-width: 40px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.10); /* slightly calmer */
    }

    /* Make "Vad" feel tappable but not too loud */
    .proposal-details-trigger {
        text-decoration-thickness: 1px;
        text-underline-offset: 2px;
    }

    /* Compact status badges on tiny screens */
    .status-badge {
        padding: 5px 8px;
        font-size: 12px;
        font-weight: 800;
    }

    /* If status badge wraps, it becomes tall; keep it compact */
    .table td:nth-child(3) .status-badge {
        line-height: 1.15;
    }
    /* Align content to top when rows grow in height */
    .table td {
        vertical-align: top;
    }

    /* Give status badge a little top spacing so it doesn't hug text */
    .status-badge {
        margin-top: 2px;
    }

    /* Keep the gear visually aligned with the first text line */
    td.actions {
        vertical-align: top;
        padding-top: 10px;
    }
    /* Allow very long single words in "Vad" to wrap instead of breaking layout */
    .table td:first-child,
    .proposal-details-trigger {
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    /* Top header: allow wrapping on small screens */
    .top {
        flex-wrap: wrap;
        gap: 10px;
        align-items: flex-start;
    }

    /* Let the right side drop below and align nicely */
    .top-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

        /* Make links/buttons a bit more tappable without taking too much space */
        .top-actions .btn-link,
        .top-actions button {
            padding: 9px 12px;
        }
}
/* ===============================
   Proposal Images UI (details modal)
   - public/js/images/proposalImagesUI.js
   =============================== */

.details-images {
    margin-top: 14px;
}

/* Root wrapper */
.pi-root {
    margin-top: 6px;
}

/* Header row: title + upload controls */
.pi-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.pi-title {
    margin: 0;
    font-size: 16px;
}

/* Upload row */
.pi-upload {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.10);
    background: rgba(255,255,255,0.80);
}

.pi-upload-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 0; /* override global label margin-top */
    min-width: 180px;
    flex: 1;
}

.pi-category {
    width: 100%;
}

.pi-files {
    width: 100%;
    padding: 10px;
}

.pi-upload-hint {
    font-size: 12px;
    opacity: 0.75;
    line-height: 1.25;
    flex-basis: 100%;
}

/* Buttons in images UI (reuse your base button styles) */
.pi-btn {
    margin-top: 0; /* override global button margin-top */
}

.pi-btn-upload {
    white-space: nowrap;
}

/* “Danger” variant (match your style) */
.pi-btn-danger {
    color: #7a0b0b;
    background: linear-gradient(180deg, #ffecec, #ffd2d2);
    border: 1px solid #f0a0a0;
}

    .pi-btn-danger:hover {
        background: linear-gradient(180deg, #fff2f2, #ffc4c4);
    }

/* Sections */
.pi-sections {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pi-section {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.10);
    background: rgba(255,255,255,0.70);
}

.pi-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.pi-section-title {
    margin: 0;
    font-size: 14px;
}

.pi-count {
    font-size: 12px;
    opacity: 0.70;
}

/* Grid of thumbnails */
.pi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.pi-empty {
    font-size: 13px;
    opacity: 0.75;
}

/* Item card */
.pi-item {
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 12px;
    background: rgba(255,255,255,0.85);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pi-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

    .pi-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

.pi-img-error {
    opacity: 0.6;
    filter: grayscale(1);
}

.pi-meta {
    padding: 8px 10px 6px 10px;
}

.pi-filename {
    font-size: 12px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pi-sub {
    margin-top: 2px;
    font-size: 12px;
    opacity: 0.7;
}

.pi-actions {
    padding: 8px 10px 10px 10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Loading */
.pi-loading {
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.10);
    background: rgba(255,255,255,0.85);
    font-weight: 700;
    opacity: 0.9;
}

/* Responsive */
@media (max-width: 900px) {
    .pi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 650px) {
    .pi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .pi-upload {
        padding: 10px;
    }

    .pi-upload-label {
        min-width: 100%;
    }

    .pi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
}
/* ===============================
   Image lightbox (fullscreen image viewer)
   - public/js/images/imageLightbox.js
   =============================== */

.ilb-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
}

    .ilb-overlay.is-hidden {
        display: none;
    }

.ilb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.88);
}

/* Container that holds toolbar + image area */
.ilb-shell {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Top bar (close + zoom) */
.ilb-toolbar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.0));
}

.ilb-title {
    color: rgba(255,255,255,0.85);
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55vw;
}

.ilb-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Buttons (reuse your base button styling, but darker) */
button.ilb-btn {
    margin-top: 0; /* override global button margin-top */
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.95);
    background: rgba(255,255,255,0.10);
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    font-weight: 800;
}

    button.ilb-btn:hover {
        filter: brightness(1.05);
        background: rgba(255,255,255,0.14);
    }

    button.ilb-btn:active {
        transform: translateY(1px);
    }

    button.ilb-btn:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px rgba(91,156,255,0.35), 0 2px 10px rgba(0,0,0,0.25);
    }

    button.ilb-btn[disabled] {
        opacity: 0.45;
        cursor: not-allowed;
        transform: none !important;
    }

/* Image viewport */
.ilb-viewport {
    position: relative;
    flex: 1;
    min-height: 0; /* allow flex child to shrink */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* important: we pan inside */
    touch-action: none; /* we handle gestures in JS */
}

/* The image itself (we scale/translate via JS) */
.ilb-img {
    max-width: 100%;
    max-height: 100%;
    transform-origin: center center;
    will-change: transform;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none; /* so drags go to viewport */
}

/* Help text (optional) */
.ilb-hint {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 2;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(0,0,0,0.35);
    color: rgba(255,255,255,0.85);
    font-size: 12px;
    font-weight: 700;
    max-width: calc(100% - 24px);
}

/* Mobile polish */
@media (max-width: 520px) {
    .ilb-toolbar {
        padding: 10px 10px;
    }

    .ilb-title {
        max-width: 48vw;
    }

    button.ilb-btn {
        padding: 8px 10px;
        min-width: 44px; /* touch friendly */
    }

    .ilb-hint {
        font-size: 11px;
        padding: 7px 9px;
    }
}
