/* ==========================================================================
   DirectStay — Foglio di stile centralizzato (Portale Pubblico & Gestione)
   ========================================================================== */

:root {
    --bg: #F6F1EA;
    --surface: #FFFDF9;
    --ink: #1E1B18;
    --muted: #6E655D;
    --rt-muted: #6E655D;
    --line: rgba(30, 27, 24, 0.11);
    --line-strong: rgba(30, 27, 24, 0.18);
    --accent: #B8522E;
    --accent-ink: #8E3A1D;
    --accent-hover: #9E4B2B;
    --ok-bg: #E6F4EA;
    --ok-ink: #1E6B38;
    --warn-bg: #FEF3C7;
    --warn-ink: #92400E;
    --err-bg: #FEE2E2;
    --err-ink: #991B1B;
}

/* --------------------------------------------------------------------------
   1. PORTALE PUBBLICO (Home, Scheda Casa, Prenotazioni, Area Ospiti)
   -------------------------------------------------------------------------- */
body.ds-portal {
    overflow-x: clip !important;
}

/* Barra di ricerca Home centrata e rialzata */
body.ds-portal .hero .bar-slot {
    max-width: 980px;
    width: 100%;
    margin-inline: auto;
}

body.ds-portal .hero .bar {
    box-shadow: 0 18px 44px rgba(30, 27, 24, 0.12);
    border: 1px solid rgba(30, 27, 24, 0.10);
}

body.ds-portal .hero .trust {
    max-width: 980px;
    margin-inline: auto;
}

body.ds-portal .site-header .pill {
    box-shadow: 0 10px 30px rgba(30, 27, 24, 0.08);
    border: 1px solid rgba(30, 27, 24, 0.08);
}

/* Griglia foto stile Airbnb + Booking Card sticky (Scheda Struttura) */
.airbnb-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: 220px 220px;
    gap: 10px;
    border-radius: 20px;
    overflow: hidden;
}
.airbnb-grid .main-photo { grid-row: span 2; }
.airbnb-grid--two {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 440px;
}
.airbnb-grid--two .main-photo { grid-row: span 1; }
.airbnb-grid--single {
    grid-template-columns: 1fr;
    grid-template-rows: 440px;
}
.airbnb-grid--single .main-photo { grid-row: span 1; }

.booking-rail {
    position: relative;
    height: 100%;
}
.sticky-booking {
    position: -webkit-sticky;
    position: sticky;
    top: 104px;
    z-index: 20;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.sticky-booking.is-floating {
    box-shadow: 0 20px 48px rgba(30, 27, 24, 0.14) !important;
    border-color: rgba(30, 27, 24, 0.22) !important;
}

#quote-breakdown.hidden,
#booking-check-btn.hidden {
    display: none !important;
}
#quote-breakdown:not(.hidden) {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-booking-bar {
    display: none;
}

@media (max-width: 1023px) {
    .sticky-booking { position: static; }
    .mobile-booking-bar {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 40;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        padding: 14px 20px;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--line-strong);
        box-shadow: 0 -8px 24px rgba(30, 27, 24, 0.08);
    }
}

@media (max-width: 768px) {
    .airbnb-grid,
    .airbnb-grid--two,
    .airbnb-grid--single {
        grid-template-columns: 1fr;
        grid-template-rows: 280px;
    }
    .airbnb-grid .sub-photo { display: none; }
}

/* --------------------------------------------------------------------------
   2. AREA GESTIONE & INTEGRAZIONI (Base comune)
   -------------------------------------------------------------------------- */
body.ds-gestione *,
body.ds-gestione-login *,
body.ds-integrazioni * {
    box-sizing: border-box;
}

body.ds-gestione,
body.ds-integrazioni {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
}

body.ds-gestione h1,
body.ds-gestione h2,
body.ds-gestione h3,
body.ds-gestione .serif,
body.ds-integrazioni h1,
body.ds-integrazioni h2,
body.ds-integrazioni h3 {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 600;
    margin: 0;
}

/* Login Staff (/gestione/login/) */
body.ds-gestione-login {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #F1EDE6;
    color: var(--ink);
    font-family: "Inter", "Plus Jakarta Sans", sans-serif;
    padding: 20px;
}
body.ds-gestione-login .box {
    background: #fff;
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 410px;
    box-shadow: 0 20px 50px rgba(30, 27, 24, 0.08);
}
body.ds-gestione-login h1 { font-family: "Cormorant Garamond", serif; font-size: 34px; margin: 0 0 6px; }
body.ds-gestione-login p { color: #6B635B; font-size: 14px; margin: 0 0 26px; }
body.ds-gestione-login label { display: block; font-size: 13px; font-weight: 600; color: #6B635B; margin-bottom: 6px; }
body.ds-gestione-login input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(30, 27, 24, 0.16); font-size: 15px; margin-bottom: 18px; }
body.ds-gestione-login button { width: 100%; padding: 13px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; }
body.ds-gestione-login .err { background: var(--err-bg); color: var(--err-ink); padding: 11px 14px; border-radius: 12px; font-size: 13.5px; margin-bottom: 18px; }

/* Layout Sidebar + Main */
.layout {
    display: grid;
    grid-template-columns: 270px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand-title {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 26px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink);
    display: block;
    line-height: 1.1;
}
.brand-sub {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 4px;
}
.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-section {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 14px 12px 6px;
}
.nav-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-list a svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-list a:hover { background: rgba(30, 27, 24, 0.05); }
.nav-list a.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-list a.nav-subitem { padding: 7px 14px 7px 32px; font-size: 13px; color: var(--muted); }
.nav-list a.nav-subitem.active { background: rgba(184, 82, 46, 0.12); color: var(--accent-ink); font-weight: 600; }

.lang-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 6px 4px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
}
.lang-btn.active { background: var(--bg); border-color: var(--line); color: var(--ink); }

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.main-area {
    padding: 36px 44px;
    max-width: 1240px;
    width: 100%;
}
.integ-wrap {
    max-width: 920px;
    margin: 36px auto;
    padding: 0 20px;
}

/* Componenti UI condivisi Backoffice */
body.ds-gestione .card,
body.ds-integrazioni .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 26px 28px;
}

body.ds-gestione .btn,
body.ds-integrazioni .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity 0.15s, background 0.15s;
}
body.ds-gestione .btn:hover,
body.ds-integrazioni .btn:hover { opacity: 0.92; }
body.ds-gestione .btn-primary,
body.ds-integrazioni .btn-primary { background: var(--accent); color: #fff; }
body.ds-gestione .btn-primary:hover,
body.ds-integrazioni .btn-primary:hover { background: var(--accent-hover); }
body.ds-gestione .btn-ghost,
body.ds-integrazioni .btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
body.ds-gestione .btn-ghost:hover,
body.ds-integrazioni .btn-ghost:hover { background: var(--bg); }

.btn-del {
    background: transparent;
    border: 1px solid rgba(185, 28, 28, 0.25);
    color: #B91C1C;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.btn-del:hover { background: var(--err-bg); }

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.field > span {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
}

body.ds-gestione input[type="text"],
body.ds-gestione input[type="email"],
body.ds-gestione input[type="url"],
body.ds-gestione input[type="number"],
body.ds-gestione input[type="password"],
body.ds-gestione input[type="date"],
body.ds-gestione select,
body.ds-gestione textarea,
body.ds-integrazioni .field-input,
body.ds-integrazioni input[type="text"],
body.ds-integrazioni input[type="email"],
body.ds-integrazioni input[type="number"],
body.ds-integrazioni input[type="password"],
body.ds-integrazioni select,
body.ds-integrazioni textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
}

.msg {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    margin-bottom: 18px;
}
.msg-success { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid rgba(30, 107, 56, 0.2); }
.msg-warning, .msg-error { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid rgba(146, 64, 14, 0.2); }

.badge-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge-err { background: var(--err-bg); color: var(--err-ink); }

.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-pending { background: var(--warn-bg); color: var(--warn-ink); }
.badge-confirmed { background: var(--ok-bg); color: var(--ok-ink); }
.badge-cancelled { background: var(--err-bg); color: var(--err-ink); }

.pill, .pill-tab {
    padding: 7px 15px;
    border-radius: 999px;
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
    cursor: pointer;
}
.pill.active, .pill-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.section-gap { margin-bottom: 28px; }
.muted { color: var(--muted); }
.row-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 8px;
}

/* Integrazioni (SMTP, PayPal, GCal, Social, Coda Email) */
.smtp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 14px; }
.smtp-kv { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.smtp-kv small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.smtp-kv strong { display: block; font-size: 15px; margin-top: 4px; word-break: break-all; }
.smtp-check-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg);
    margin-bottom: 14px;
}
.smtp-check-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 2px; }

/* Contenuti Casa & Galleria */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-top: 18px; }
.photo-item { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--bg); display: flex; flex-direction: column; }
.photo-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.photo-item-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }

/* Prenotazioni */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 22px; }
.booking-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px 24px;
    background: var(--surface);
    margin-bottom: 14px;
    display: grid;
    grid-template-columns: 1.4fr 1fr auto;
    gap: 20px;
    align-items: center;
}

/* Calendario & iCal */
.ical-box { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.ical-box small { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 4px; }

/* Centro Email */
.email-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; }
.recipient-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }

/* SEO & Indicizzazione */
.seo-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 26px; }
.seo-header h1 { font-size: 32px; line-height: 1.15; }
.seo-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.main-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.main-tab { padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink); }
.main-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.main-panel { display: none; }
.main-panel.active { display: block; }
.lang-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.lang-tab { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink); }
.lang-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.lang-panel { display: none; }
.lang-panel.active { display: block; }
.char-hint { font-size: 12px; color: var(--muted); float: right; font-weight: 500; }
.char-hint.warn { color: #B45309; font-weight: 600; }
.switch-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; background: #FAF8F5; }
.switch-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* Banner e Testi Sito */
.copy-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.copy-header h1 { font-size: 36px; line-height: 1.1; }
.copy-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); }
.copy-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.copy-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.copy-pill { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; }
.copy-pill.active { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.copy-item { border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin-bottom: 16px; background: var(--surface); }
.copy-item.is-custom { border-color: var(--accent); box-shadow: 0 4px 16px rgba(184, 92, 56, 0.08); }
.copy-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.copy-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.copy-tag.active { background: var(--ok-bg); color: var(--ok-ink); }
.copy-lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }

@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .main-area { padding: 24px 18px; }
    .email-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .booking-card { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}