/**
 * jjpwa.css
 * Personalizzazioni Drupal-specifiche per il tema JJPWA.
 * Sovrascrive e integra assets/css/style.css del tema MobileKit.
 * NON modificare style.css — usare questo file.
 *
 * INDICE
 * 1. LOADER
 * 2. HEADER
 * 3. SEARCH
 * 4. SIDEBAR
 *    4a. Offcanvas struttura
 *    4b. Profile box
 *    4c. Sidebar links (listview)
 *    4d. Sidebar buttons (footer fisso)
 * 5. BOTTOM NAVIGATION
 * 6. FOOTER
 * 7. BLOG POST
 * 8. CARD CAROUSEL
 * 9. DARK MODE
 * 10. DRUPAL UI (tabs, breadcrumb, messages, pager)
 */


/* ==========================================================================
   1. LOADER
   ========================================================================== */

#loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  opacity: 1;
  -webkit-transition: opacity 0.3s ease;
  transition: opacity 0.3s ease;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

#loader.hidden {
  opacity: 0;
  pointer-events: none;
}


/* ==========================================================================
   2. HEADER
   ========================================================================== */

.appHeader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* In modalità standalone iOS l'header parte dall'alto dello schermo fisico,
     sopra la status bar. env(safe-area-inset-top) spinge il contenuto
     sotto la status bar su tutti i dispositivi iPhone (notch, Dynamic Island). */
  min-height: calc(56px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: 8px;
  padding-right: 8px;
  padding-bottom: 0;
}

/* Forza sfondo primario e testo bianco sull'header sempre */
.appHeader {
  background-color: #0d6efd !important;
  color: #ffffff !important;
}

.appHeader .headerButton,
.appHeader .pageTitle,
.appHeader .jjpwa-hamburger {
  color: #ffffff !important;
}


/* Sinistra: hamburger + logo */
.appHeader .left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  /* Spinge il contenuto sotto la status bar iOS in modalità PWA standalone */
  margin-top: env(safe-area-inset-top, 0px);
}

/* Stessa compensazione per centro e destra */
.appHeader .pageTitle,
.appHeader .right {
  margin-top: env(safe-area-inset-top, 0px);
}

/* Hamburger Unicode — visibile sempre, non dipende da FontAwesome */
.jjpwa-hamburger {
  font-size: 1.4rem;
  line-height: 1;
  color: #ffffff;
  display: block;
}

/* Logo */
.appHeader .logo-link {
  display: flex;
  align-items: center;
  padding: 4px;
}

.appHeader .site-logo {
  height: 28px;
  width: auto;
  max-width: 80px;
  object-fit: contain;
}

/* Titolo pagina centrato */
.appHeader .pageTitle {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Destra: search */
.appHeader .right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* In modalità PWA standalone su iOS forza sfondo primario sull'header */
html.pwa-standalone .appHeader,
body.pwa-standalone .appHeader {
  background-color: #0d6efd !important;
}

/* Compensa header fisso e bottom nav tenendo conto della safe area iOS */
#appCapsule {
  padding-top: calc(56px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}


/* ==========================================================================
   3. SEARCH
   ========================================================================== */

#search {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  background: #ffffff;
  padding: 0 12px;
}

#search.show {
  display: flex;
}


/* ==========================================================================
   4. SIDEBAR
   ========================================================================== */

/* --------------------------------------------------
   4a. Offcanvas struttura — flex column per sticky footer
   -------------------------------------------------- */

#sidebarPanel {
  display: flex !important;
  flex-direction: column !important;
}

#sidebarPanel .offcanvas-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-bottom: 0;
}

/* --------------------------------------------------
   4b. Profile box
   -------------------------------------------------- */

.profileBox {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.profileBox .image-wrapper {
  flex-shrink: 0;
}

.profileBox .image-wrapper img {
  width: 48px;
  height: 48px;
  object-fit: cover;
}

.profileBox .in {
  flex: 1;
  min-width: 0;
}

.profileBox .in strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.close-sidebar-button {
  margin-left: auto;
  padding: 8px;
  font-size: 1.4rem;
  color: inherit;
  opacity: 0.6;
  transition: opacity 0.18s ease;
}

.close-sidebar-button:hover {
  opacity: 1;
}

/* --------------------------------------------------
   4c. Sidebar links (listview voci menu)
   -------------------------------------------------- */

/* Dark mode toggle — solo nella sidebar */
.dark-mode-switch {
  cursor: pointer;
}

/* --------------------------------------------------
   4d. Sidebar buttons — footer fisso 50px
   -------------------------------------------------- */

.sidebar-buttons {
  flex-shrink: 0 !important;
  height: 50px;
  min-height: 50px;
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: inherit;
}

/* Rende trasparenti i wrapper <div> (region) e <nav> (block) inseriti da Drupal
   così i figli .button partecipano direttamente al flex del contenitore */
.sidebar-buttons > div,
.sidebar-buttons nav {
  display: contents;
}

.sidebar-buttons h2.visually-hidden {
  display: none;
}

/* Link contenitore — occupa quota uguale */
.sidebar-buttons .button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0%;
  height: 100%;
  text-decoration: none;
}

/* Cerchio icona — dimensioni fisse su <i> perché FontAwesome
   sovrascrive width:auto sull'<svg> inline */
.sidebar-buttons .button i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50% !important;
  background: rgba(13, 110, 253, 0.15);
  color: #0d6efd;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.18s ease, color 0.18s ease;
}

/* Reimposta l'SVG iniettato da FA per non interferire col cerchio */
.sidebar-buttons .button i svg {
  width: 1em !important;
  height: 1em !important;
  background: none !important;
  border-radius: 0 !important;
}

.sidebar-buttons .button:hover i,
#block-jjpwa-sidebarbuttons a:hover,
#block-jjpwa-sidebarbuttons a:hover svg {
  background: #0d6efd;
  color: #ffffff;
}

#block-jjpwa-sidebarbuttons a svg {
  color: #0d6efd;
}


/* ==========================================================================
   5. BOTTOM NAVIGATION
   ========================================================================== */

.appBottomMenu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: stretch;
  justify-content: center;
  height: 64px;
  background: #ffffff;
  box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.10);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  margin: 0;
}

/* Wrapper <div> (region) e <nav> (block) inseriti da Drupal — trasparenti al flex */
.appBottomMenu > div,
.appBottomMenu nav {
  display: contents;
}

/* Gruppo sinistra: voci menu del bottom nav */
.appBottomMenu div .left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Gruppo destra: hamburger — posizionato in assoluto a destra */
.appBottomMenu div .right {
  display: flex;
  position: absolute;
  align-items: center;
  flex-shrink: 0;
  right: 8px;
  top: 0;
}

.appBottomMenu h2.visually-hidden {
  display: none;
}

/* Ogni voce — larghezza adattata al contenuto, padding orizzontale generoso */
.appBottomMenu .jjpwa-bottom-item {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 72px;
  padding: 8px 16px 6px;
  height: 100%;
  color: #9e9e9e;
  font-size: 1.4rem;
  line-height: 1;
  text-decoration: none;
  position: relative;
  border-top: 2px solid transparent;
  box-sizing: border-box;
  transition: color 0.18s ease;
}

.appBottomMenu .jjpwa-bottom-item.active,
.appBottomMenu .jjpwa-bottom-item:hover {
  color: #0d6efd;
  border-top-color: #0d6efd;
}

/* Etichetta testo sotto l'icona — non troncare */
.appBottomMenu .jjpwa-bottom-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 500;
  margin-top: 4px;
  white-space: nowrap;
  text-align: center;
}


/* ==========================================================================
   6. FOOTER
   ========================================================================== */

.jjpwa-footer {
  padding: 16px 0 0;
  margin-top: 24px;
}

/* Riga 1: larghezza intera */
.jjpwa-footer-top {
  padding: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}

/* Riga 2: 4 colonne (Bootstrap col-12 → col-sm-6 → col-md-3) */
.jjpwa-footer-cols {
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  margin-top: 8px;
}

.jjpwa-footer-col {
  padding: 16px;
}


/* ==========================================================================
   7. BLOG POST
   ========================================================================== */

.blog-post {
  padding: 0 16px;
}

.blog-post .title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 16px;
  margin-bottom: 8px;
}

.blog-post .post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #6c757d;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.blog-post .post-header a {
  display: flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
}

.blog-post .post-body {
  line-height: 1.7;
}

.blog-post .post-body img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 12px 0;
}

.blog-post .post-body h2 {
  font-size: 1.2rem;
  margin-top: 20px;
}

.blog-post .post-body h4 {
  font-size: 1rem;
  margin-top: 16px;
}

.blog-post .field--name-field-image img {
  width: 100%;
  height: auto;
  display: block;
}


/* ==========================================================================
   8. CARD CAROUSEL (Splide)
   ========================================================================== */

.carousel-multiple .card {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.carousel-multiple .card-img-wrapper img,
.carousel-multiple .card-img-top {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.carousel-multiple .splide__slide {
  padding: 4px;
}


/* ==========================================================================
   9. DARK MODE
   ========================================================================== */

body.dark-mode {
  background-color: #1a1a2e;
  color: #e0e0e0;
}

body.dark-mode .appHeader {
  background-color: #16213e !important;
}

body.dark-mode #search,
body.dark-mode .appBottomMenu {
  background-color: #16213e;
}

body.dark-mode .card {
  background-color: #0f3460;
  border-color: #1a1a2e;
}

body.dark-mode .offcanvas {
  background-color: #16213e;
  color: #e0e0e0;
}

body.dark-mode .jjpwa-footer {
  background-color: #16213e;
}


/* ==========================================================================
   10. DRUPAL UI
   ========================================================================== */

/* Local tasks — tab Visualizza/Modifica/ecc. come bottoni orizzontali */
.jjpwa-local-tasks {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
}

.jjpwa-local-tasks .btn {
  flex: 0 0 auto;
}

/* System messages */
.messages-list {
  margin: 8px 16px;
}

/* Tabs (modifica/vista nodo) */
.tabs--primary {
  display: flex;
  list-style: none;
  padding: 8px 16px 0;
  margin: 0;
  gap: 4px;
  overflow-x: auto;
}

.tabs--primary .tabs__tab a {
  display: block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  background: rgba(13, 110, 253, 0.1);
  color: #0d6efd;
  text-decoration: none;
  white-space: nowrap;
}

.tabs--primary .tabs__tab.is-active a {
  background: #0d6efd;
  color: #ffffff;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.8rem;
  padding: 8px 16px;
  background: transparent;
}

/* Pager */
.pager {
  display: flex;
  justify-content: center;
  padding: 16px;
  list-style: none;
  gap: 4px;
}


/* ==========================================================================
   11. LOGIN FORM
   Stile MobileKit applicato al form di login Drupal (#user-login-form).
   Nessun template aggiuntivo — solo CSS mirato sulle classi Drupal.
   ========================================================================== */

/* Contenitore del form */
#user-login-form {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* Immagine decorativa simulata con icona FA sopra il form */
#user-login-form::before {
  content: '';
  display: block;
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  background: rgba(13, 110, 253, 0.1);
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512'%3E%3Cpath fill='%230d6efd' d='M256 16c0-7 4.5-13.2 11.2-15.3s13.9 .4 17.9 6.1l224 320c3.4 4.9 3.8 11.3 1.1 16.6s-8.2 8.6-14.2 8.6H272c-8.8 0-16-7.2-16-16V16zM212.1 96.5c7 1.9 11.9 8.2 11.9 15.5V336c0 8.8-7.2 16-16 16H80c-5.7 0-11-3-13.8-8s-2.9-11-.1-16l128-224c3.6-6.3 11-9.4 18-7.5zM5.7 404.3C2.8 394.1 10.5 384 21.1 384H554.9c10.6 0 18.3 10.1 15.4 20.3l-4 14.3C550.7 473.9 500.4 512 443 512H133C75.6 512 25.3 473.9 9.7 418.7l-4-14.3z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 44px;
}

/* Titolo e sottotitolo sopra il form */
#user-login-form::after {
  display: none;
}

/* Blocco titolo — aggiunto via page--user--login o visibile nel content */
.page-user-login h1.page-title,
#block-jjpwa-page-title h1 {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

/* Label degli input — nascoste, i placeholder bastano */
#user-login-form .form-item label {
  font-size: 0.8rem;
  color: #6c757d;
  margin-bottom: 4px;
  display: block;
}

/* Input username e password — stile MobileKit boxed */
#user-login-form input[type="text"],
#user-login-form input[type="password"] {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #f8f9fa;
  box-sizing: border-box;
  transition: border-color 0.18s ease, background 0.18s ease;
  -webkit-appearance: none;
}

#user-login-form input[type="text"]:focus,
#user-login-form input[type="password"]:focus {
  outline: none;
  border-color: #0d6efd;
  background: #ffffff;
}

/* Spaziatura tra i campi */
#user-login-form .form-item {
  margin-bottom: 12px;
}

/* Link "Password dimenticata" e "Registrati" */
#user-login-form .form-item--pass-pass {
  margin-bottom: 0;
}

#user-login-form > .form-item:last-of-type {
  margin-bottom: 16px;
}

/* Pulsante submit — full width, grande, stile MobileKit */
#user-login-form .form-actions {
  margin-top: 8px;
}

#user-login-form .form-actions input[type="submit"],
#user-login-form .form-actions button[type="submit"] {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 10px;
  background: #0d6efd;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease;
  -webkit-appearance: none;
}

#user-login-form .form-actions input[type="submit"]:hover,
#user-login-form .form-actions button[type="submit"]:hover {
  background: #0b5ed7;
}

/* Link sotto il form (password dimenticata, registrazione) */
.user-login-links,
#block-jjpwa-page-title + * .item-list {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px 0;
  max-width: 480px;
  margin: 0 auto;
  font-size: 0.85rem;
}
