/* CalabriaVera — final UI rules loaded last on every built page. */
:root{--cv-shell-navy:#00345b}
html{min-height:100%;height:auto!important;background:var(--cv-shell-navy)!important;overflow-x:hidden!important;overflow-y:auto!important;overscroll-behavior-y:auto!important;touch-action:auto!important}
body{min-height:100vh;height:auto!important;margin:0!important;padding-top:0!important;background:var(--cv-shell-navy)!important;overflow-x:hidden!important;overflow-y:visible!important;overscroll-behavior-y:auto!important;touch-action:auto!important;-webkit-overflow-scrolling:touch}
#site-header{position:sticky!important;top:0!important;z-index:5000!important;background:var(--cv-shell-navy)!important}
.site-header.cv-header{position:relative!important;top:auto!important;left:auto!important;right:auto!important;width:100%!important;z-index:auto!important;background:var(--cv-shell-navy)!important}
#main-content{margin:0!important;background:#fff;overflow:visible!important;touch-action:auto!important}
#site-footer,.footer{background:var(--cv-shell-navy)!important}
.footer{margin-top:0!important;border-top:0!important;padding-bottom:max(3rem,env(safe-area-inset-bottom))!important}

/* Evita che l'audit generale spezzi parole normali come "Conversazioni". */
:where(h1,h2,h3,h4,.eyebrow,label,button,.button,summary){overflow-wrap:normal!important;word-break:normal!important;hyphens:none!important}
:where(h1,h2,h3,h4){max-width:100%;text-wrap:balance}
:where(input,select,textarea,button,.button){min-width:0;max-width:100%}
:where(.card,.notice,.empty-state,.stat,.form-grid,.grid-2,.grid-3,.grid-4,.section-heading)>*{min-width:0}
.form-actions,.filter-actions,.meta-row{flex-wrap:wrap}

/* Le aree personali mantengono un titolo leggibile senza scala "hero". */
body[data-page="dashboard"] #main-content,
body[data-page="favorites"] #main-content,
body[data-page="messages"] #main-content,
body[data-page="profile"] #main-content,
body[data-page="addBusiness"] #main-content,
body[data-page="login"] #main-content,
body[data-page="register"] #main-content{background:#f7f9fb!important}
body[data-page="dashboard"] #main-content>.section.container>h1,
body[data-page="favorites"] #main-content>.section.container>h1,
body[data-page="messages"] #main-content>.section.container>h1,
body[data-page="profile"] #main-content>.section.container>h1,
body[data-page="addBusiness"] #main-content>.section.container>h1,
body[data-page="login"] #main-content>.section.container>h1,
body[data-page="register"] #main-content>.section.container>h1{font-size:clamp(2rem,4.2vw,3.45rem)!important;line-height:1.04!important;margin:.2rem 0 1.1rem!important;letter-spacing:-.035em!important}
body[data-page="dashboard"] #dashboard-root,
body[data-page="favorites"] #favorites-root,
body[data-page="messages"] #messages-root,
body[data-page="profile"] #profile-root,
body[data-page="addBusiness"] #add-business-root,
body[data-page="login"] #auth-root,
body[data-page="register"] #auth-root{width:100%;min-width:0;max-width:100%}

/* Form, card e azioni delle aree account devono restringersi senza overflow. */
body[data-page="profile"] .grid-2,
body[data-page="addBusiness"] .form-grid,
body[data-page="login"] .form-grid,
body[data-page="register"] .form-grid{min-width:0}
body[data-page="profile"] .card,
body[data-page="dashboard"] .card,
body[data-page="favorites"] .card,
body[data-page="addBusiness"] .card,
body[data-page="login"] .card,
body[data-page="register"] .card{max-width:100%;min-width:0}
body[data-page="profile"] a,
body[data-page="dashboard"] a,
body[data-page="favorites"] a,
body[data-page="addBusiness"] a{overflow-wrap:break-word}

/* Esplora e Mappa: Servizio e Data non devono essere visibili nei filtri. */
body[data-page="catalog"] #service,
body[data-page="catalog"] #date,
body[data-page="map"] #service{display:none!important}

/* Fallback difensivo: la lista attività della Mappa non deve mai essere mostrata. */
body[data-page="map"] #map-results{display:none!important}

/* Messaggi: layout stabile, titoli leggibili, più respiro e niente icone chatbot-like. */
body[data-page="messages"] #main-content>.section.container{width:min(calc(100% - 40px),1440px)!important;padding:28px 0 42px!important}
body[data-page="messages"] .cv-messages-shell{grid-template-columns:minmax(300px,350px) minmax(0,1fr)!important;width:100%!important;max-width:100%!important;height:clamp(540px,68dvh,720px)!important;min-height:540px!important;margin-top:14px!important}
body[data-page="messages"] .cv-conversations-panel,
body[data-page="messages"] .cv-thread-panel{min-width:0!important}
body[data-page="messages"] .cv-messages-panel-head{display:flex!important;align-items:flex-start!important;justify-content:space-between!important;gap:12px!important;padding:20px 22px 14px!important;min-width:0!important}
body[data-page="messages"] .cv-messages-panel-head>div{min-width:0!important}
body[data-page="messages"] .cv-messages-panel-head h2{font-size:clamp(1.65rem,2.15vw,2.15rem)!important;line-height:1.08!important;margin:.25rem 0 .35rem!important;overflow-wrap:normal!important;word-break:normal!important;hyphens:none!important}
body[data-page="messages"] .cv-conversation-total{flex:0 0 auto!important;margin-top:4px!important}
body[data-page="messages"] .cv-conversation-list{padding:10px 14px 16px!important}
body[data-page="messages"] .cv-conversation-row{min-width:0!important}
body[data-page="messages"] .cv-conversation-copy,
body[data-page="messages"] .cv-conversation-top{min-width:0!important}
body[data-page="messages"] .cv-messages-empty{padding:18px 2px 22px!important}
body[data-page="messages"] .cv-messages-empty p{max-width:28ch!important}
body[data-page="messages"] .cv-thread-heading{padding:20px 24px 18px!important;min-width:0!important}
body[data-page="messages"] .cv-thread-heading>div,
body[data-page="messages"] .cv-thread-contact>div{min-width:0!important}
body[data-page="messages"] .cv-thread-heading h2{font-size:clamp(1.8rem,3vw,2.75rem)!important;line-height:1.06!important;margin:.25rem 0 .55rem!important;overflow-wrap:normal!important;word-break:normal!important;hyphens:none!important}
body[data-page="messages"] .cv-thread-heading p{max-width:62ch!important;margin-bottom:0!important}
body[data-page="messages"] .cv-thread{padding:24px!important}
body[data-page="messages"] .cv-message-composer{grid-template-columns:minmax(0,1fr) auto!important;padding:16px 20px 18px!important;gap:10px!important;align-items:stretch!important}
body[data-page="messages"] .cv-message-composer input{min-width:0!important;font-size:16px!important}
body[data-page="messages"] .cv-send-button{display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:8px!important;width:auto!important;min-width:104px!important;max-width:160px!important;white-space:nowrap!important;padding-inline:16px!important}
body[data-page="messages"] .cv-send-button svg{display:block!important;width:18px!important;height:18px!important;min-width:18px!important;max-width:18px!important;flex:0 0 18px!important}
body[data-page="messages"] .cv-thread-placeholder{padding:28px 4px!important}
body[data-page="messages"] .cv-thread-placeholder p{margin:0!important}
body[data-page="messages"] .cv-empty-icon,
body[data-page="messages"] .cv-thread-placeholder>span[aria-hidden="true"]{display:none!important}

/* Dashboard, preferiti e profilo: azioni e griglie scalano senza uscire dal viewport. */
body[data-page="dashboard"] .stat-grid{grid-template-columns:repeat(4,minmax(0,1fr))!important}
body[data-page="dashboard"] .form-actions,
body[data-page="favorites"] .cv-favorite-actions,
body[data-page="profile"] .form-actions,
body[data-page="addBusiness"] .form-actions{gap:8px!important}
body[data-page="favorites"] .cv-favorite-body h2{overflow-wrap:normal!important;word-break:normal!important}
body[data-page="profile"] form,
body[data-page="addBusiness"] form,
body[data-page="login"] form,
body[data-page="register"] form{min-width:0;max-width:100%}

/* Admin: i contenuti possono scorrere orizzontalmente solo nelle tabelle, non nella pagina. */
body[data-page^="admin-"] .admin-layout,
body[data-page^="admin-"] .admin-layout>section,
body[data-page^="admin-"] #admin-content{min-width:0!important;max-width:100%!important}
body[data-page^="admin-"] .table-wrap{width:100%!important;max-width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch}
body[data-page^="admin-"] table{min-width:620px}

@media(max-width:980px){
  body[data-page="messages"] .cv-messages-shell{grid-template-columns:minmax(260px,300px) minmax(0,1fr)!important}
  body[data-page="messages"] .cv-messages-panel-head h2{font-size:1.65rem!important}
  body[data-page="messages"] .cv-thread-heading h2{font-size:clamp(1.7rem,4vw,2.25rem)!important}
  body[data-page="dashboard"] .stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}

@media(max-width:820px){
  body[data-page="messages"] #main-content>.section.container{width:min(calc(100% - 28px),1440px)!important;padding-top:22px!important}
  body[data-page="messages"] .cv-messages-shell{grid-template-columns:1fr!important;height:auto!important;min-height:0!important}
  body[data-page="messages"] .cv-conversations-panel{max-height:330px!important;border-right:0!important;border-bottom:1px solid #e2e8ee!important}
  body[data-page="messages"] .cv-thread-panel{min-height:500px!important}
  body[data-page="messages"] .cv-thread{min-height:280px!important}
}

@media(max-width:720px){
  body[data-page="catalog"] #results.result-list{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px!important;
    width:100%!important;
  }
  body[data-page="catalog"] #results>.activity-item{
    min-width:0!important;
    width:auto!important;
    margin:0!important;
    min-height:225px!important;
  }
  body[data-page="catalog"] #results>.activity-item .media-placeholder{height:112px!important}
  body[data-page="catalog"] #results>.activity-item h3{font-size:12px!important;line-height:1.2!important}
  body[data-page="catalog"] #results>.activity-item p{font-size:10px!important;line-height:1.3!important;-webkit-line-clamp:2!important}

  /* Eventi & Blog / notizie: due card affiancate anche su smartphone. */
  body[data-page="blog"] #blog-list.card-grid{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:8px!important;
    width:100%!important;
  }
  body[data-page="blog"] #blog-list>.blog-card{min-width:0!important;width:auto!important;margin:0!important;overflow:hidden!important}
  body[data-page="blog"] #blog-list>.blog-card .body{padding:9px!important}
  body[data-page="blog"] #blog-list>.blog-card .eyebrow{font-size:9px!important;line-height:1.25!important}
  body[data-page="blog"] #blog-list>.blog-card h3{font-size:13px!important;line-height:1.2!important;margin:5px 0!important;display:-webkit-box!important;-webkit-box-orient:vertical!important;-webkit-line-clamp:3!important;overflow:hidden!important}
  body[data-page="blog"] #blog-list>.blog-card .body>p:not(.eyebrow){font-size:10px!important;line-height:1.3!important;display:-webkit-box!important;-webkit-box-orient:vertical!important;-webkit-line-clamp:3!important;overflow:hidden!important}
  body[data-page="blog"] #blog-list>.blog-card .text-link{font-size:10px!important}
}

@media(max-width:760px){
  body[data-page="dashboard"] #main-content>.section.container>h1,
  body[data-page="favorites"] #main-content>.section.container>h1,
  body[data-page="messages"] #main-content>.section.container>h1,
  body[data-page="profile"] #main-content>.section.container>h1,
  body[data-page="addBusiness"] #main-content>.section.container>h1,
  body[data-page="login"] #main-content>.section.container>h1,
  body[data-page="register"] #main-content>.section.container>h1{font-size:clamp(1.85rem,9vw,2.6rem)!important}
  body[data-page="messages"] .cv-messages-panel-head{padding:16px 16px 10px!important}
  body[data-page="messages"] .cv-conversation-list{padding:8px 10px 12px!important}
  body[data-page="messages"] .cv-thread-heading{padding:16px!important}
  body[data-page="messages"] .cv-thread{padding:18px 14px!important}
  body[data-page="messages"] .cv-message-composer{padding:12px 14px 14px!important}
  body[data-page="profile"] .grid-2,
  body[data-page="addBusiness"] .form-grid{grid-template-columns:1fr!important}
  body[data-page="profile"] .form-actions,
  body[data-page="dashboard"] .form-actions,
  body[data-page="addBusiness"] .form-actions{display:grid!important;grid-template-columns:1fr!important}
  body[data-page="profile"] .form-actions>* ,
  body[data-page="dashboard"] .form-actions>* ,
  body[data-page="addBusiness"] .form-actions>*{width:100%!important}
}

@media(max-width:560px){
  body[data-page="messages"] #main-content>.section.container{width:calc(100% - 20px)!important;padding:18px 0 28px!important}
  body[data-page="messages"] .cv-messages-shell{margin-top:10px!important;border-radius:13px!important}
  body[data-page="messages"] .cv-conversations-panel{max-height:300px!important}
  body[data-page="messages"] .cv-thread-panel{min-height:450px!important}
  body[data-page="messages"] .cv-messages-panel-head h2{font-size:1.5rem!important}
  body[data-page="messages"] .cv-thread-heading h2{font-size:1.65rem!important}
  body[data-page="messages"] .cv-message-composer{grid-template-columns:1fr!important}
  body[data-page="messages"] .cv-send-button{width:100%!important;max-width:none!important;min-width:0!important}
  body[data-page="messages"] .cv-message-bubble{max-width:94%!important}
  body[data-page="dashboard"] .stat-grid{grid-template-columns:1fr!important}
  body[data-page="favorites"] .cv-favorite-actions{grid-template-columns:1fr!important}
  body[data-page^="admin-"] .admin-layout>aside{max-width:100%!important;overflow-x:auto!important}
}

@media(max-width:380px){
  body[data-page="messages"] .cv-thread-heading{flex-direction:column!important;align-items:flex-start!important}
  body[data-page="messages"] .cv-thread-business-link{width:100%!important;text-align:center!important}
}
