/* ============================================================
   Cercami Favorites — Stili
   ============================================================ */

/* Bottone cuore */
.cf-heart-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all .2s;
    color: #6c757d;
    font-size: .85rem;
    font-weight: 500;
}

.cf-heart-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #343a40;
}

.cf-heart-btn.cf-active {
    background: #fff0f0;
    border-color: #e8b4b8;
    color: #e03131;
}

.cf-heart-btn.cf-active .cf-heart-icon {
    fill: #e03131;
}

.cf-heart-icon {
    transition: transform .2s;
}

.cf-heart-btn:hover .cf-heart-icon {
    transform: scale(1.1);
}

.cf-heart-btn-small {
    padding: 4px 8px;
}

.cf-heart-btn-small .cf-heart-icon {
    width: 16px;
    height: 16px;
}

.cf-heart-label {
    display: inline;
}

/* Pagina preferiti */
.cf-favorites-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
}

.cf-favorites-header {
    text-align: center;
    margin-bottom: 24px;
}

.cf-favorites-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.cf-favorites-subtitle {
    color: #6c757d;
    font-size: .95rem;
}

/* Loading */
.cf-favorites-loading {
    text-align: center;
    padding: 40px;
}

.cf-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top-color: #4a9d6f;
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: cf-spin .8s linear infinite;
}

@keyframes cf-spin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.cf-favorites-empty {
    text-align: center;
    padding: 60px 20px;
}

.cf-empty-icon {
    margin-bottom: 16px;
    opacity: .4;
}

.cf-empty-text {
    color: #6c757d;
    font-size: .95rem;
    margin-bottom: 16px;
}

.cf-btn-search {
    display: inline-block;
    background: #4a9d6f;
    color: #fff;
    text-decoration: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: .9rem;
    font-weight: 500;
    transition: background .2s;
}

.cf-btn-search:hover {
    background: #3d8a5c;
}

/* Lista card */
.cf-favorites-list {
    display: grid;
    gap: 16px;
}

.cf-card {
    display: flex;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow .2s;
    min-height: 120px;
}

.cf-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.cf-card-thumb-wrap {
    width: 120px;
    flex-shrink: 0;
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

.cf-card-thumb {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.cf-card-thumb-placeholder {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 2rem;
}

.cf-card-content {
    flex: 1;
    padding: 16px;
}

.cf-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.cf-card-title a {
    color: #2c3e50;
    text-decoration: none;
}

.cf-card-title a:hover {
    color: #4a9d6f;
}

.cf-card-meta {
    font-size: .8rem;
    color: #6c757d;
    margin-bottom: 8px;
}

.cf-card-address {
    font-size: .85rem;
    color: #495057;
    margin-bottom: 8px;
}

.cf-card-excerpt {
    font-size: .85rem;
    color: #6c757d;
    line-height: 1.5;
    margin: 0 0 12px 0;
}

.cf-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.cf-btn-view {
    display: inline-block;
    background: #4a9d6f;
    color: #fff;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: .82rem;
    font-weight: 500;
    transition: background .2s;
}

.cf-btn-view:hover {
    background: #3d8a5c;
}

.cf-btn-remove-card {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: .8rem;
    color: #6c757d;
    transition: all .2s;
}

.cf-btn-remove-card:hover {
    background: #fff0f0;
    border-color: #e8b4b8;
    color: #e03131;
}

/* Azioni pagina */
.cf-favorites-actions {
    text-align: center;
    margin-top: 20px;
}

.cf-btn-remove-all {
    background: none;
    border: 1px solid #e8b4b8;
    color: #e03131;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .85rem;
    transition: all .2s;
}

.cf-btn-remove-all:hover {
    background: #fff0f0;
}

/* Toast notification */
.cf-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #2c3e50;
    color: #fff;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: .9rem;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

/* ---- Banner Privacy ---- */
.cf-privacy-banner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    background: #e8f4fd;
    border: 1px solid #b8d9f5;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 20px;
    font-size: .88rem;
    color: #1a5276;
}

.cf-privacy-banner-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.cf-privacy-icon { font-size: 1.2rem; flex-shrink: 0; }

.cf-privacy-text strong { display: block; margin-bottom: 2px; }

.cf-privacy-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #1a5276;
    font-size: 1rem;
    padding: 0 4px;
    flex-shrink: 0;
    opacity: .6;
}
.cf-privacy-close:hover { opacity: 1; }

/* ---- Toolbar ---- */
.cf-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.cf-toolbar-distance {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cf-btn-locate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: #fff;
    border: 1px solid #adb5bd;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: .85rem;
    box-sizing: border-box;
    transition: all .2s;
}
.cf-btn-locate:hover { background: #e9ecef; }
.cf-btn-locate:disabled { opacity: .6; cursor: default; }

.cf-address-wrap {
    display: flex;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

.cf-address-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: .85rem;
    box-sizing: border-box;
}

.cf-btn-calc-addr {
    flex-shrink: 0;
    background: #4a9d6f;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: .85rem;
    transition: background .2s;
}
.cf-btn-calc-addr:hover { background: #3d8a5c; }
.cf-btn-calc-addr:disabled { opacity: .6; }

.cf-toolbar-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    border-top: 1px solid #dee2e6;
    padding-top: 8px;
}

.cf-toolbar-sort label {
    white-space: nowrap;
    flex-shrink: 0;
}

.cf-sort-select {
    flex: 1;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: .85rem;
}

/* ---- Raggruppamento categorie ---- */
.cf-category-group { margin-bottom: 28px; }

.cf-category-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #4a9d6f;
    padding-bottom: 6px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cf-cat-count {
    background: #4a9d6f;
    color: #fff;
    border-radius: 20px;
    padding: 1px 8px;
    font-size: .75rem;
    font-weight: 500;
}

/* ---- Card top + distanza ---- */
.cf-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.cf-card-top .cf-card-title { margin: 0; flex: 1; }

.cf-distance-badge {
    background: #e8f4fd;
    color: #1a5276;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: .75rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.cf-card-phone {
    font-size: .85rem;
    color: #495057;
    margin-bottom: 8px;
}
.cf-card-phone a { color: #495057; text-decoration: none; }
.cf-card-phone a:hover { color: #4a9d6f; }

/* ---- Bottone note ---- */
.cf-btn-notes {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: .8rem;
    color: #6c757d;
    transition: all .2s;
}
.cf-btn-notes:hover { background: #f8f9fa; border-color: #adb5bd; }
.cf-btn-notes.cf-has-notes { border-color: #4a9d6f; color: #4a9d6f; }

/* ---- Pannello note ---- */
.cf-notes-panel {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    margin-top: 10px;
}

.cf-notes-field-wrap { margin-bottom: 10px; }
.cf-notes-field-wrap:last-of-type { margin-bottom: 6px; }

.cf-notes-label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
}

.cf-referents-field,
.cf-note-field {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: .84rem;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color .2s;
}
.cf-referents-field:focus,
.cf-note-field:focus { border-color: #4a9d6f; outline: none; }

.cf-notes-saved {
    display: none;
    font-size: .78rem;
    color: #4a9d6f;
    font-weight: 500;
}

/* ---- Pannello backup ---- */
.cf-backup-panel {
    background: #f0f8f4;
    border: 1px solid #b2dfcc;
    border-radius: 8px;
    padding: 20px;
    margin-top: 28px;
}

.cf-backup-title {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 6px 0;
}

.cf-backup-desc {
    font-size: .85rem;
    color: #6c757d;
    margin-bottom: 14px;
}

.cf-backup-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cf-backup-option {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cf-backup-option-desc {
    font-size: .8rem;
    color: #6c757d;
    line-height: 1.3;
}

.cf-btn-export-json,
.cf-btn-export-qr,
.cf-btn-import-label {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #adb5bd;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: .84rem;
    background: #fff;
    color: #495057;
    transition: all .2s;
    white-space: nowrap;
}
.cf-btn-export-json:hover,
.cf-btn-export-qr:hover,
.cf-btn-import-label:hover {
    background: #e9ecef;
    border-color: #6c757d;
}

/* ---- Modal QR ---- */
.cf-qr-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cf-qr-modal-inner {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,.2);
    max-width: 320px;
    width: 90%;
}

.cf-qr-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    font-size: .95rem;
}

.cf-qr-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: #6c757d;
    padding: 0 4px;
}
.cf-qr-close:hover { color: #343a40; }

.cf-qr-modal-body {
    padding: 20px;
    text-align: center;
}

#cf-qr-canvas {
    display: inline-block;
    margin-bottom: 12px;
}

.cf-qr-hint {
    font-size: .82rem;
    color: #6c757d;
    margin: 0 0 6px 0;
}

.cf-qr-hint-warning {
    font-size: .78rem;
    color: #856404;
    background: #fff3cd;
    border-radius: 4px;
    padding: 6px 8px;
    margin-top: 8px;
}


/* ---- Badge contatore menu ---- */
.cf-menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dc3545;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 9px;
    padding: 0 4px;
    margin-left: 5px;
    vertical-align: middle;
    line-height: 1;
}

/* ---- Badge distanza cliccabile ---- */
.cf-distance-clickable {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
    white-space: nowrap;
}
.cf-distance-clickable:hover {
    background: #c8e6c9;
    transform: scale(1.04);
}

.cf-distance-hint {
    font-size: .72rem;
    font-weight: 400;
    opacity: .75;
}

/* ---- Modale percorso ---- */
.cf-route-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cf-route-modal-inner {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 92vw;
    max-width: 900px;
    height: 85vh;
    max-height: 700px;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

.cf-route-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a73e8;
    color: #fff;
    padding: 12px 16px;
    gap: 12px;
    flex-shrink: 0;
    font-size: .9rem;
    font-weight: 600;
}

.cf-route-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.cf-route-btn-steps {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.4);
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: .82rem;
    transition: background .2s;
}
.cf-route-btn-steps:hover,
.cf-route-btn-steps.active { background: #fff; color: #1a73e8; }

.cf-route-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    opacity: .8;
}
.cf-route-close:hover { opacity: 1; }

.cf-route-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#cf-route-steps {
    width: 280px;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid #dee2e6;
    background: #fafafa;
}

#cf-route-map {
    flex: 1;
    min-height: 200px;
}

.cf-route-error {
    padding: 8px 16px;
    background: #fff3cd;
    color: #856404;
    font-size: .85rem;
    flex-shrink: 0;
}

@media (max-width: 576px) {
    .cf-route-modal-inner {
        width: 100vw;
        height: 100dvh;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .cf-route-modal-body { flex-direction: column; }
    #cf-route-steps {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
        max-height: 35vh;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .cf-card {
        flex-direction: column;
        min-height: auto;
    }

    .cf-card-thumb-wrap {
        width: 100%;
        height: 120px;
        max-height: 120px;
    }

    .cf-card-thumb {
        height: 120px;
        width: 100%;
        object-fit: contain;
        object-position: center;
    }

    .cf-card-thumb-placeholder {
        height: 120px;
        width: 100%;
    }

    .cf-card-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .cf-btn-view,
    .cf-btn-remove-card,
    .cf-btn-notes {
        text-align: center;
        justify-content: center;
    }

    /* ---- Backup mobile ---- */
    .cf-backup-option {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .cf-btn-export-json,
    .cf-btn-export-qr,
    .cf-btn-import-label {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    .cf-card-top { flex-direction: column; gap: 4px; }
}
