/* ── Stili condivisi dell'area amministrazione (pagine /admin/*) ── */

/* Le pagine admin (riconoscibili dalla topbar) sono contenute e con padding,
   come le sezioni pubbliche del template */
.page-body:has(.admin-topbar) {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 2.5rem 1.5rem 3rem;
}

/* ── Login ── */
.login-wrap {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: white;
    border-radius: 20px;
    padding: 2.5rem 2rem;
    width: min(380px, calc(100% - 2rem));
    box-shadow: 0 12px 40px rgba(0,0,0,.1);
    text-align: center;
}
.login-logo { font-size: 3rem; margin-bottom: 1rem; }
.login-card h4 { margin-bottom: 1.5rem; font-weight: 700; }

/* ── Topbar ── */
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.admin-topbar h2 { margin: 0; font-weight: 800; font-size: 1.5rem; color: #1d2b2f; }

/* ── Dashboard cards ── */
.dash-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.dash-card {
    background: white;
    border-radius: 16px;
    padding: 1.25rem 1rem;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.06);
    border-left: 4px solid #08465c;
}
.dash-card.warn  { border-color: #f6c96d; }
.dash-card.muted { border-color: #adb5bd; }
.dash-card.green { border-color: #198754; }
.dash-card-icon  { font-size: 1.6rem; margin-bottom: .4rem; }
.dash-card-val   { font-size: 1.5rem; font-weight: 800; color: #1d2b2f; }
.dash-card-label { font-size: .8rem; color: #607176; margin-top: .2rem; }

/* ── Booking chips ── */
.booking-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.25rem;
}
.bchip {
    padding: .3rem .8rem;
    border-radius: 999px;
    font-size: .8rem;
    background: #e9ecef;
    color: #495057;
}
.bchip strong { font-size: .95rem; }
.bchip-confirmed { background: #d1e7dd; color: #0a3622; }
.bchip-pending   { background: #fff3cd; color: #664d03; }
.bchip-cancelled { background: #e2e3e5; color: #41464b; }

/* ── Booking table ── */
.booking-table th { font-size: .8rem; white-space: nowrap; }
.booking-table td { font-size: .85rem; }

/* ── File Manager ── */
.upload-area {
    position: relative;
    border: 2px dashed #b0c4cc;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    text-align: center;
    background: white;
    margin-bottom: 1.5rem;
    transition: border-color .2s, background .2s;
    cursor: pointer;
}
.upload-area:hover,
.upload-area.drag-over {
    border-color: #08465c;
    background: #e8f4f8;
}
.upload-input-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.upload-icon  { font-size: 2.5rem; margin-bottom: .5rem; pointer-events: none; }
.upload-label { font-weight: 600; color: #1d2b2f; margin: 0 0 .75rem; pointer-events: none; }
.upload-hint  { font-size: .8rem; color: #607176; margin: .5rem 0 0; pointer-events: none; }
.pe-none      { pointer-events: none; }

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}
.file-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
    transition: box-shadow .2s;
}
.file-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.13); }
.file-thumb {
    aspect-ratio: 1;
    overflow: hidden;
    background: #f0f4f8;
}
.file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.file-info {
    padding: .5rem .6rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.file-name {
    font-size: .75rem;
    color: #1d2b2f;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-actions { display: flex; gap: .3rem; }
.btn-xs {
    padding: .15rem .45rem;
    font-size: .75rem;
    border-radius: 6px;
    border-width: 1px;
    cursor: pointer;
}

/* ── Staging panel ── */
.staging-panel {
    background: white;
    border-radius: 16px;
    border: 2px solid #f6c96d;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.staging-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    color: #1d2b2f;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: .5rem;
}
.staging-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: .9rem 0;
    border-top: 1px solid #eef2f4;
    transition: opacity .2s;
}
.staging-row.staging-saved { opacity: .5; }
.staging-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    background: #f0f4f8;
}
.staging-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.staging-fields { flex: 1; min-width: 0; }
.staging-filename {
    font-size: .75rem;
    font-weight: 700;
    color: #607176;
    margin-bottom: .5rem;
}
.staging-action { flex-shrink: 0; padding-top: .25rem; }

/* ── File card badge DB ── */
.file-thumb { position: relative; }
.db-badge {
    position: absolute;
    top: 5px; right: 5px;
    font-size: .6rem;
    font-weight: 800;
    padding: .15rem .4rem;
    border-radius: 6px;
    letter-spacing: .03em;
}
.db-badge-yes { background: #198754; color: white; }
.db-badge-no  { background: #adb5bd; color: white; }

/* ── Delete modal ── */
.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-box {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    width: min(380px, calc(100% - 2rem));
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-box h5 { font-weight: 700; margin-bottom: .75rem; }
.modal-box p  { color: #607176; margin-bottom: 1rem; }

/* ── Edit modal ── */
.modal-box-lg {
    width: min(760px, calc(100% - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1.5rem;
}
.edit-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.edit-modal-header h5 { margin: 0; font-weight: 700; }
.edit-modal-body {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}
.edit-preview {
    flex-shrink: 0;
    width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}
.edit-preview img {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 12px;
    background: #f0f4f8;
}
.edit-filename {
    font-size: .72rem;
    color: #607176;
    font-weight: 600;
    word-break: break-all;
    text-align: center;
}
.edit-fields { flex: 1; min-width: 0; }

@media (max-width: 600px) {
    .edit-modal-body { flex-direction: column; }
    .edit-preview { width: 100%; }
    .edit-preview img { width: 100%; height: 200px; }
}

@media (max-width: 700px) {
    .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ── S3 Media ── */
.s3-toolbar { margin-bottom: 1rem; }
.s3-toolbar-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.s3-thumb-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f4f8;
    border-radius: 10px;
}
.s3-file-icon { font-size: 2rem; }
.s3-file-icon-card {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    background: #f0f4f8;
}
.s3-file-icon-lg {
    width: 160px; height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    background: #f0f4f8;
    border-radius: 12px;
}
.s3-title {
    font-size: .72rem;
    color: #607176;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Video thumbnail ── */
.s3-video-thumb-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.s3-video-thumb-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;   /* no accidental play on hover in grid */
}
/* In the edit modal the video gets controls so allow interaction */
.s3-video-edit-preview video {
    pointer-events: auto;
    border-radius: 12px;
}
.s3-video-edit-preview {
    width: 160px;
    height: 160px;
    border-radius: 12px;
}
/* Play badge overlay */
.s3-play-badge {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,.55);
    color: white;
    font-size: 1.2rem;
    width: 2.2rem; height: 2.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    backdrop-filter: blur(2px);
}
/* Staging thumb: fixed size */
.staging-thumb.s3-thumb-icon .s3-video-thumb-wrap {
    width: 80px;
    height: 80px;
    border-radius: 10px;
}

/* ── Header: dropdown Admin (componente AdminMenu dentro .header-misc, stile Canvas yacht) ── */
.header-misc { position: relative; display: flex; align-items: center; gap: .75rem; }
.header-misc .nav-admin { position: relative; }
.header-misc .nav-admin summary,
.header-misc > a:not(.az-charter-cta) {
    list-style: none;
    cursor: pointer;
    padding: .4rem .85rem;
    border-radius: 999px;
    font-family: 'Jost', system-ui, sans-serif;
    font-size: .82rem;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #0D2B4E;
    text-decoration: none;
    white-space: nowrap;
    transition: color .2s, background .2s;
}
.header-misc .nav-admin summary::-webkit-details-marker { display: none; }
.header-misc .nav-admin summary:hover,
.header-misc .nav-admin[open] summary,
.header-misc > a:not(.az-charter-cta):hover { background: rgba(13,43,78,.07); color: #A07828; }

.header-misc .nav-admin-panel {
    position: absolute;
    top: calc(100% + .5rem);
    right: 0;
    background: white;
    border-radius: 4px;
    border-top: 3px solid #C9A84C;
    box-shadow: 0 12px 40px rgba(8,29,53,.2);
    padding: .5rem;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    z-index: 950;
}
.header-misc .nav-admin-panel a,
.header-misc .nav-admin-panel .nav-signout {
    display: block;
    width: 100%;
    padding: .5rem .85rem;
    border: none;
    border-radius: 4px;
    background: none;
    font-family: 'Jost', system-ui, sans-serif;
    font-size: .88rem;
    font-weight: 500;
    color: #0D2B4E !important;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
}
.header-misc .nav-admin-panel a:hover,
.header-misc .nav-admin-panel a.active,
.header-misc .nav-admin-panel .nav-signout:hover {
    background: rgba(201,168,76,.14);
    color: #A07828 !important;
}
.header-misc .nav-admin-panel .nav-signout {
    border-top: 1px solid #eef2f4;
    margin-top: .25rem;
    color: #b02a37 !important;
}

/* ── Dropdown Admin su mobile/tablet (< lg 992px) ──
   L'header Canvas su mobile può ritagliare o coprire il pannello a tendina:
   lo ancoriamo al bordo destro del viewport, alziamo lo z-index sopra l'header
   e impediamo il clipping degli antenati. Il chip resta sempre visibile. */
@media (max-width: 991.98px) {
    /* gli antenati non devono tagliare il menu a tendina */
    #header, #header-wrap, #header .header-row, .header-misc, .header-misc .nav-admin {
        overflow: visible !important;
    }

    /* chip "Admin ▾" / "Area riservata" sempre leggibile e toccabile */
    .header-misc .nav-admin summary,
    .header-misc > a:not(.az-charter-cta) {
        background: rgba(13,43,78,.08);
        border: 1px solid rgba(13,43,78,.15);
        padding: .45rem .8rem;
        font-size: .8rem;
    }

    /* pannello: ancorato sotto il chip (top automatico), pinnato a destra,
       mai più largo del viewport, sopra ogni elemento dell'header */
    .header-misc .nav-admin-panel {
        right: 0;
        left: auto;
        min-width: 220px;
        max-width: calc(100vw - 1.5rem);
        z-index: 1100;
        box-shadow: 0 16px 48px rgba(8,29,53,.28);
    }
    .header-misc .nav-admin-panel a,
    .header-misc .nav-admin-panel .nav-signout {
        padding: .7rem .9rem;   /* tap target più ampio */
        font-size: .95rem;
    }
}

/* Anteprima sezioni articolo */
.mg-preview-section { padding: .5rem 0; border-bottom: 1px dashed #e3e8ee; }
.mg-preview-section:last-child { border-bottom: none; }
.mg-preview-hidden { opacity: .55; }
.mg-preview-section img { max-width: 100%; height: auto; }

/* TinyMCE: i popup (menu, dialog "code"/link) devono stare sopra le modali admin (z-index 2000) */
.tox.tox-tinymce-aux, .tox-tinymce-aux { z-index: 2100 !important; }

/* Anteprima HTML renderizzato nella tabella sezioni */
.mg-section-preview {
    max-height: 140px;
    overflow: auto;
    border: 1px solid #e3e8ee;
    border-radius: 6px;
    padding: .4rem .6rem;
    background: #fff;
    font-size: .85rem;
}
.mg-section-preview img { max-width: 100%; height: auto; }
.mg-section-preview iframe { max-width: 100%; }
.mg-section-preview p:last-child { margin-bottom: 0; }

/* ── File manager ───────────────────────────────────── */
.mg-fm {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1rem;
    align-items: start;
}
@media (max-width: 768px) {
    .mg-fm { grid-template-columns: 1fr; }
}
.mg-fm-tree {
    background: #fff;
    border: 1px solid #e3e9ea;
    border-radius: 10px;
    padding: .75rem;
    position: sticky;
    top: 1rem;
}
.mg-fm-tree-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    color: #1d2b2f;
    margin-bottom: .5rem;
}
.mg-fm-folders { list-style: none; margin: 0; padding: 0; }
.mg-fm-folders li { margin: 1px 0; }
.mg-fm-folder {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 6px;
    padding: .3rem .5rem;
    font-size: .9rem;
    color: #2a3b40;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mg-fm-folder:hover { background: #eef3f4; }
.mg-fm-folder.active { background: #1d2b2f; color: #fff; }
.mg-fm-guide { color: #9aa9ad; margin-right: .15rem; font-family: monospace; }
.mg-fm-folder.active .mg-fm-guide { color: #cdd6d8; }
.mg-fm-caret { display: inline-block; width: .9rem; color: #6b7a7f; font-size: .7rem; text-align: center; user-select: none; }
.mg-fm-folder.active .mg-fm-caret { color: #cdd6d8; }
.mg-fm-folder-ico { margin-right: .15rem; }

/* ── Card sentence nascosta ─────────────────────────── */
.file-card { position: relative; }
.mg-hidden-card { opacity: .62; }
.mg-hidden-card .file-thumb { filter: grayscale(.7); }
.mg-hidden-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    background: #b45309;
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    padding: .12rem .4rem;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.mg-fm-content {
    background: #fff;
    border: 1px solid #e3e9ea;
    border-radius: 10px;
    padding: 1rem;
    min-height: 300px;
}
.mg-fm-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    border-bottom: 1px solid #eef3f4;
    padding-bottom: .6rem;
}
.mg-fm-path { font-weight: 700; color: #1d2b2f; }
.mg-fm-fileicon { margin-right: .25rem; }

/* ── Pannello filtri admin (sentences) ──────────────── */
.admin-filter-panel {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid #e3e9ea;
    border-radius: 10px;
    padding: .8rem 1rem;
}
.admin-filter { display: flex; flex-direction: column; gap: .2rem; }
.admin-filter .form-select, .admin-filter .form-control { min-width: 200px; }
