:root {
    color-scheme: light;
    font-family: "Segoe UI", Arial, sans-serif;
    --violet: #6520b6;
    --pink: #ff4fa2;
    --bg: #f4f5fb;
    --text: #1f2333;
    --card: #eef0f4;
    --card-panel-bg: #f3e8ff;
    --card-shadow: 3px 4px 10px rgba(101, 32, 182, 0.22);
    --muted: #5f6780;
    --white: #ffffff;
    --border: #d9dce5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

.app {
    min-height: 100vh;
    padding-bottom: 90px;
}

.container {
    width: min(1100px, 100% - 24px);
    margin: 0 auto;
}

.header {
    background: var(--violet);
    color: var(--white);
    border-radius: 0 0 18px 18px;
    padding: 20px 0 18px;
    box-shadow: 0 8px 24px rgba(28, 8, 56, 0.35);
}

.header-brand {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    margin-bottom: 14px;
    text-align: right;
}

.header-app-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    flex-shrink: 0;
    object-fit: cover;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    background: rgba(255, 255, 255, 0.12);
}

.header-app-name {
    margin: 0;
    font-size: clamp(1.75rem, 6.5vw, 2.15rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 0.02em;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-top {
    display: flex;
    gap: 12px;
    align-items: center;
}

.header-intro {
    margin-top: 12px;
}

.user-badge {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pink);
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 1.21rem;
    flex-shrink: 0;
}

.intro {
    margin: 0;
    line-height: 1.35;
    font-size: 1.21rem;
}

.header-auth {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
}

.header-auth-btn {
    border: 0;
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 1.21rem;
    font-weight: 700;
    cursor: pointer;
    background: #f3e8ff;
    color: var(--violet);
}

.header-auth-btn.secondary {
    background: rgba(255, 255, 255, 0.22);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.45);
}

.header-auth-out {
    margin-left: auto;
    font-size: 1.129333rem;
    font-weight: 600;
    color: var(--white);
    text-decoration: underline;
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop.open {
    display: flex;
}

.modal {
    background: var(--white);
    color: var(--text);
    border-radius: 14px;
    width: min(420px, 100%);
    max-height: 90vh;
    overflow: auto;
    padding: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.modal h2 {
    margin: 0 0 12px;
    font-size: 1.5125rem;
}

.modal label {
    display: block;
    font-size: 1.21rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.req-mark {
    color: #dc2626;
    font-weight: 800;
}

.modal input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 1.310833rem;
}

.password-field {
    position: relative;
    margin-bottom: 12px;
}

.modal .password-field input {
    margin-bottom: 0;
    padding-right: 46px;
}

.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: #000;
    cursor: pointer;
    padding: 4px;
    width: 30px;
    height: 30px;
    line-height: 0;
}

.toggle-password svg {
    width: 20px;
    height: 20px;
    display: block;
    pointer-events: none;
}

.modal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.modal-actions button {
    flex: 1;
    min-width: 120px;
    border: 0;
    border-radius: 10px;
    padding: 10px;
    font-weight: 700;
    cursor: pointer;
}

.modal-actions .primary {
    background: var(--violet);
    color: var(--white);
}

.modal-actions .ghost {
    background: #e8eaf0;
    color: var(--text);
}

.modal-link-row {
    margin: -4px 0 12px;
    text-align: right;
}

.modal-link-button {
    border: 0;
    background: none;
    color: var(--violet);
    font-size: 1.2584rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.modal-msg {
    font-size: 1.419733rem;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 10px;
    display: none;
}

.modal-msg.error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
}

.modal-msg.ok {
    display: block;
    background: #dcfce7;
    color: #166534;
}

.search-wrap {
    margin-top: 14px;
}

.search-input {
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 9px 10px;
    font-size: 1.310833rem;
    outline: none;
}

.search-wrap .search-input:focus {
    outline: none;
}

.body {
    padding-top: 16px;
}

.switcher {
    background: var(--white);
    border-radius: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    box-shadow: 0 6px 16px rgba(17, 23, 49, 0.07);
}

.tab-button {
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 10px;
    padding: 10px;
    font-size: 1.310833rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text);
}

.tab-button.active {
    border-color: var(--violet);
    color: var(--violet);
    background: #f6f0ff;
}

.panel {
    margin-top: 14px;
}

.hidden {
    display: none;
}

#map {
    width: 100%;
    min-height: 54vh;
    border-radius: 14px;
    background: #d8ddf2;
    box-shadow: 0 10px 25px rgba(2, 6, 23, 0.1);
}

.map-price-popup {
    position: absolute;
    transform: translate(-50%, -38px);
    background: #fff;
    border: 1px solid #111827;
    border-radius: 999px;
    color: #111827;
    font-weight: 800;
    white-space: nowrap;
    line-height: 1;
    padding: 2px 5px 8px;
    font-size: 1.21rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
    pointer-events: none;
}

.status {
    margin-top: 8px;
    color: var(--muted);
    font-size: 1.21rem;
    line-height: 1.35;
}

.list-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: end;
    margin-bottom: 10px;
}

.list-title {
    margin: 0;
    font-size: 1.815rem;
    line-height: 1.25;
}

.list-subtitle {
    margin-top: 0;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 1.310833rem;
    line-height: 1.35;
}

.list-controls {
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 6px 14px rgba(18, 26, 53, 0.06);
    margin-bottom: 12px;
}

.list-search-line {
    margin: 0 0 5px;
    font-size: 1.310833rem;
    line-height: 1.35;
    color: var(--muted);
}

#list-panel .list-controls .search-input {
    border: 1px solid var(--violet);
    color: var(--text);
    font-size: 1.613333rem;
    line-height: 1.35;
    padding: 9px 10px;
    min-height: 2.2183rem;
}

#list-panel .list-controls .search-input::placeholder {
    color: var(--muted);
    opacity: 1;
}

.filters-section-title {
    margin: 10px 0 6px;
    font-size: 1.411667rem;
    line-height: 1.3;
    font-weight: 700;
    color: var(--violet);
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
}

#list-panel .filters {
    background: var(--violet);
    margin-top: 8px;
    padding: 9px 10px;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(101, 32, 182, 0.35);
    gap: 10px;
}

#list-panel .filter-row {
    gap: 6px 8px;
}

#list-panel .filter-button {
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

#list-panel .filter-button:hover {
    background: rgba(255, 255, 255, 0.24);
}

#list-panel .filter-button.active {
    border-color: #fff;
    color: var(--violet);
    background: #fff;
}

/* Filtro specifico selezionato (non «Tutte») */
#list-panel .filter-button.is-filter-applied,
#list-panel .filter-button.active.is-filter-applied {
    border-color: #ffcc00;
    color: var(--violet);
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18), 0 0 0 2px #ffcc00;
    font-weight: 700;
}

#list-panel .list-controls.has-active-filters .filters-section-title::after {
    content: " (attivi)";
    font-weight: 700;
    color: #ffcc00;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filters .filter-row .filter-button,
.filter-button {
    border: 1px solid var(--border);
    background: #f8f9fc;
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 1.310833rem;
    line-height: 1.3;
    font-weight: 600;
    cursor: pointer;
    min-height: 1.815rem;
}

.filters .filter-row .filter-button.active,
.filter-button.active {
    border-color: var(--violet);
    color: var(--violet);
    background: #f5efff;
    font-size: 1.310833rem;
    line-height: 1.3;
}

#list-panel .filters .filter-button,
#list-panel .filters .filter-button.active {
    font-size: 1.310833rem;
    line-height: 1.3;
    min-height: 1.815rem;
    padding: 7px 11px;
}

.cards {
    display: grid;
    gap: 16px;
}

.restaurant-card {
    background: var(--card-panel-bg);
    border-radius: 14px;
    padding: 14px 16px;
    text-align: left;
    box-shadow: var(--card-shadow);
}

.card-top {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.restaurant-photo {
    width: 86px;
    height: 86px;
    border-radius: 10px;
    object-fit: cover;
    background: #d9dde8;
    flex-shrink: 0;
}

#list-panel .restaurant-name {
    margin: 0;
    font-size: 1.714167rem;
    line-height: 1.25;
}

.restaurant-link {
    color: inherit;
    text-decoration: none;
}

.restaurant-link:hover {
    text-decoration: underline;
}

.card-meta-block {
    margin: 6px 0 4px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.card-meta-line {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    background: #ea580c;
    color: #fff;
    border-radius: 0;
    padding: 7px 11px;
    font-size: 1.310833rem;
    font-weight: 600;
    line-height: 1.25;
}

.card-price {
    margin: 0;
    color: #0b7a1f;
    font-weight: 700;
    font-size: 1.411667rem;
    line-height: 1.35;
}

.card-line {
    margin: 6px 0 0;
    font-size: 1.310833rem;
    line-height: 1.4;
    color: #2f354b;
}

.footer-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f3e8ff;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    z-index: 20;
}

.nav-item {
    text-decoration: none;
    color: #3e4560;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 9px 4px;
    font-size: 1.21rem;
    font-weight: 600;
}

.nav-item.active {
    color: var(--violet);
}

.nav-icon {
    font-size: 1.855333rem;
}

@media (min-width: 768px) {
    .header {
        padding-top: 24px;
    }

    .user-badge {
        width: 48px;
        height: 48px;
        font-size: 1.371333rem;
    }

    .intro {
        font-size: 1.411667rem;
    }

    .list-title {
        font-size: 2.178rem;
    }

    .list-subtitle,
    .list-search-line {
        font-size: 1.411667rem;
    }

    .filters-section-title {
        font-size: 1.5125rem;
    }

    .filter-button,
    #list-panel .filters .filter-button {
        font-size: 1.411667rem;
        padding: 8px 13px;
    }

    #list-panel .restaurant-name {
        font-size: 1.915833rem;
    }

    .card-meta-line {
        font-size: 1.411667rem;
        padding: 9px 14px;
    }

    .card-price {
        font-size: 1.5125rem;
    }

    .card-line {
        font-size: 1.411667rem;
    }

    .restaurant-photo {
        width: 96px;
        height: 96px;
    }

    .list-header {
        margin-bottom: 12px;
    }

    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #map {
        min-height: 63vh;
    }
}

@media (min-width: 1024px) {
    .cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* restaurants.php — solo lista */
.restaurants-page .switcher,
.restaurants-page #map-panel {
    display: none !important;
}

.restaurants-page #list-panel {
    display: block !important;
    margin-top: 0;
}

/* Titoli e header scheda: dimensioni in restaurant-fields.css */

.restaurants-page .header .back-link {
    color: var(--white);
    text-decoration: none;
    font-weight: 700;
    display: inline-block;
    margin-bottom: 10px;
}

.restaurants-page .header .page-detail-title {
    margin: 0;
}

/* Lista restaurants.php — schede separate, sfondo violetto chiaro */
.restaurants-page #list-panel .cards {
    gap: 18px;
}

.restaurants-page #list-panel .restaurant-card {
    background: var(--card-panel-bg) !important;
    border: 1px solid #e9d5ff;
    border-radius: 14px;
    padding: 14px 16px;
    text-align: left;
    box-shadow: var(--card-shadow);
}

/* Scheda dettaglio (restaurant.php) */
.restaurants-page.restaurant-detail-page .card.restaurant-card,
.restaurants-page.restaurant-detail-page section.card.restaurant-card {
    margin-top: 14px;
    background: var(--card);
    border: none;
    border-radius: 14px;
    padding: 12px;
    text-align: left;
}

.restaurant-detail-page .card.restaurant-card,
.restaurant-detail-page section.card.restaurant-card {
    overflow: hidden;
}
