/* ============================================================
   TNC Post – Stili Frontend  v2.1
   ============================================================ */

/* ---- Wrapper ---- */
.as-front-wrap {
    max-width: 780px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1e1e1e;
}

/* ---- Selettore tipo ---- */
.as-tipo-section {
    border: 2px solid #2271b1;
    background: #f0f6fc;
}
.as-tipo-select {
    font-size: 16px;
    font-weight: 600;
    color: #2271b1;
    cursor: pointer;
}

/* ---- Header ---- */
.as-front-header { margin-bottom: 24px; }
.as-front-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
    color: #1e1e1e;
}
.as-front-byline { font-size: 13px; color: #666; margin: 0; }

/* ---- Sezioni ---- */
.as-front-section {
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 10px;
    padding: 20px 22px;
    margin-bottom: 16px;
}

.as-front-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #1e1e1e;
}
.as-required { color: #c02b2b; }
.as-front-hint {
    font-size: 12px;
    color: #777;
    margin: 0 0 12px;
    line-height: 1.5;
}

/* ---- Input / Textarea ---- */
.as-front-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c5c5c5;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.as-front-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34,113,177,.15);
    outline: none;
}

.as-front-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c5c5c5;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    resize: vertical;
    min-height: 180px;
    line-height: 1.6;
    font-family: inherit;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.as-front-textarea:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34,113,177,.15);
    outline: none;
}

/* ---- Foto sociale ---- */
.as-social-zone { cursor: pointer; }

.as-social-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px dashed #c5c5c5;
    border-radius: 8px;
    padding: 32px 20px;
    text-align: center;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.as-social-placeholder:hover {
    border-color: #2271b1;
    background: #f0f6fc;
    color: #2271b1;
}
.as-social-placeholder span:first-child { font-size: 32px; line-height: 1; }

.as-social-preview-wrap {
    position: relative;
    display: inline-block;
}
.as-social-preview-wrap img {
    width: 100%;
    max-width: 420px;
    height: 220px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    display: block;
}

.as-remove-btn {
    position: absolute;
    top: -10px; right: -10px;
    width: 28px; height: 28px;
    background: #c02b2b;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
    transition: background .15s;
}
.as-remove-btn:hover { background: #9b1c1c; }

/* ---- Galleria ---- */
.as-gallery-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}
.as-gallery-thumb-item {
    position: relative;
    width: 90px;
    height: 90px;
    flex-shrink: 0;
}
.as-gallery-thumb-item img {
    width: 90px; height: 90px;
    object-fit: cover;
    border-radius: 7px;
    border: 2px solid #e0e0e0;
    display: block;
}
.as-gallery-thumb-remove {
    position: absolute;
    top: -8px; right: -8px;
    width: 22px; height: 22px;
    background: #c02b2b;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.as-gallery-count { font-size: 12px; color: #777; margin: 0 0 10px; }
.as-gallery-warn  { font-size: 12px; color: #c02b2b; font-weight: 600; margin: 0 0 10px; }

/* ---- Bottone "Aggiungi foto" galleria ---- */
.as-front-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid #8c8f94;
    background: #fff;
    color: #1e1e1e;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s;
    line-height: 1.4;
}
.as-front-btn:hover {
    background: #f6f7f7;
    border-color: #444;
    color: #1e1e1e;
    text-decoration: none;
}

/* ---- Categorie ---- */
.as-front-cats { display: flex; flex-wrap: wrap; gap: 8px; }
.as-front-cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    user-select: none;
}
.as-front-cat-pill:hover { background: #f0f6fc; border-color: #2271b1; }
.as-front-cat-pill input[type="checkbox"] { margin: 0; accent-color: #2271b1; cursor: pointer; }
.as-front-cat-pill:has(input:checked) {
    background: #e8f0fb;
    border-color: #2271b1;
    font-weight: 600;
    color: #2271b1;
}

/* ---- Riga prezzo/quantità ---- */
.as-front-row { display: flex; gap: 20px; flex-wrap: wrap; }
.as-front-field { flex: 1; min-width: 140px; }
.as-front-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #444; }

/* ================================================================
   BARRA AZIONI — due bottoni in fondo, sempre visibili
   ================================================================ */
.as-front-actions {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: #fff;
    border-top: 1px solid #e2e2e2;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 -4px 20px rgba(0,0,0,.08);
    padding: 14px 22px;
    display: flex;
    align-items: center;
    margin-top: 8px;
}

.as-actions-create,
.as-actions-edit {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}
.as-actions-edit { justify-content: flex-end; }

/* Nasconde una delle due fasi */
.as-hidden { display: none !important; }

/* ---- Bottone base azione ---- */
.as-act-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 26px;
    border-radius: 7px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
    white-space: nowrap;
    line-height: 1.3;
    min-width: 150px;
}
.as-act-btn:disabled { opacity: .55; cursor: not-allowed; }

/* Ghost / Bozza / Modifica */
.as-act-ghost {
    background: #fff;
    border-color: #8c8f94;
    color: #3c434a;
}
.as-act-ghost:hover {
    background: #f6f7f7;
    border-color: #3c434a;
    color: #1e1e1e;
    text-decoration: none;
}

/* Primary / Pubblica */
.as-act-primary {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    margin-left: auto; /* spinge a destra */
}
.as-act-primary:hover {
    background: #135e96;
    border-color: #135e96;
    color: #fff;
}

/* Green / Aggiorna */
.as-act-green {
    background: #1a7340;
    border-color: #1a7340;
    color: #fff;
    margin-left: auto;
}
.as-act-green:hover {
    background: #145730;
    border-color: #145730;
    color: #fff;
}

/* ================================================================
   BANNER FEEDBACK (successo / errore)
   ================================================================ */
.as-front-banner {
    padding: 13px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    line-height: 1.5;
    animation: asBannerIn .2s ease;
}
@keyframes asBannerIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.as-banner-success {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    color: #1b5e20;
}
.as-banner-error {
    background: #ffeaea;
    border: 1px solid #ffb3b3;
    color: #7a0000;
}
.as-banner-warn {
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #6d4c00;
}

/* ================================================================
   NOTICE (accesso negato, errori strutturali)
   ================================================================ */
.as-notice {
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.as-notice-warn  { background: #fff8e1; border: 1px solid #ffe082; color: #6d4c00; }
.as-notice-error { background: #ffeaea; border: 1px solid #ffb3b3; color: #7a0000; }
.as-notice-info  { background: #e3f2fd; border: 1px solid #90caf9; color: #0d47a1; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 600px) {
    .as-front-section  { padding: 16px 14px; }
    .as-front-actions  { padding: 12px 14px; border-radius: 0; }
    .as-front-row      { flex-direction: column; gap: 12px; }
    .as-act-btn        { font-size: 14px; padding: 10px 16px; min-width: 0; flex: 1; }
    .as-actions-create,
    .as-actions-edit   { gap: 8px; }
    .as-act-primary,
    .as-act-green      { margin-left: 0; }
    .as-social-preview-wrap img { max-width: 100%; height: 180px; }
}

/* ============================================================
   GALLERIA SLIDER (popup a scorrimento)
   ============================================================ */
.as-lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, .78);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.as-lightbox-overlay.as-lb-open {
    display: flex;
    animation: as-lb-fadein .18s ease;
}
@keyframes as-lb-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.as-lightbox-box {
    position: relative;
    width: min(80vw, 624px);
    background: #1a1a1a;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 12px 60px rgba(0,0,0,.7);
    cursor: default;
    display: flex;
    flex-direction: column;
}
/* ---- Barra superiore (contatore + chiudi) ---- */
.as-lb-topbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    box-sizing: border-box;
    background: rgba(0,0,0,.6);
    flex-shrink: 0;
}
.as-lb-counter {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    letter-spacing: .5px;
}
.as-lightbox-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    border: 1.5px solid rgba(255,255,255,.5);
    font-size: 15px;
    cursor: pointer;
    color: #fff;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    line-height: 1;
}
.as-lightbox-close:hover { background: rgba(255,255,255,.3); }
/* ---- Strip a scorrimento ---- */
.as-lb-strip {
    display: flex;
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;          /* Firefox */
}
.as-lb-strip::-webkit-scrollbar { display: none; } /* Chrome/Safari */
.as-lb-slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
}
.as-lb-slide img {
    display: block;
    width: 100%;
    max-height: 72vh;
    object-fit: contain;
}
/* ---- Frecce ---- */
.as-lb-arrow {
    position: absolute;
    top: calc(50% + 22px);        /* scende sotto la topbar */
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,.55);
    border: 1.5px solid rgba(255,255,255,.4);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    z-index: 5;
    padding: 0;
    line-height: 1;
}
.as-lb-arrow:hover  { background: rgba(0,0,0,.85); }
.as-lb-prev { left: 10px; }
.as-lb-next { right: 10px; }
.as-lb-arrow[disabled] { opacity: .25; pointer-events: none; }
