/*
 * Tema DMI per LibreBooking (Aulario DMI).
 * Sorgente: deploy/librebooking/tema/custom-style.css
 * Sul server: /srv/docker/librebooking/custom-style.css, montato su
 * Web/css/custom-style.css (LibreBooking lo carica dopo i suoi CSS).
 *
 * Grafica allineata a https://web.dmi.unict.it/ (Bootstrap Italia):
 * blu DMI #0078bd, testi #19191a/#17324d, carattere Titillium Web.
 * Solo CSS, nessun template. Niente color-mix(), :has(), nesting: la vista
 * monitor deve funzionare anche sul Chromium 92 dei Raspberry.
 */

/* ---------- Carattere: Titillium Web (SIL OFL 1.1), servito da Web/dmi/fonts ---------- */
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../dmi/fonts/titillium-web-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../dmi/fonts/titillium-web-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../dmi/fonts/titillium-web-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../dmi/fonts/titillium-web-600-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../dmi/fonts/titillium-web-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../dmi/fonts/titillium-web-700-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- Colori ---------- */
:root,
body[data-bs-theme] {
  --dmi-blu: #0078bd;
  --dmi-blu-scuro: #006caa;
  --dmi-blu-notte: #17324d;
  --dmi-ardesia: #30373d;
  --dmi-testo: #19191a;
  --dmi-font: 'Titillium Web', Geneva, Tahoma, sans-serif;

  /* LibreBooking: colore principale (pulsanti, link, menu) per qualunque tema */
  --primary: #0078bd;
  --primary-hover: #006caa;
  --primary-disabled: #80bbde;
  --text-color-btn: #ffffff;

  /* Griglia delle prenotazioni */
  --color-lines: #c9d1d8;
  --reservable: #ffffff;
  --reserved: #d3e7f5;
  --unreservable: #e8edf1;
  --pasttime: #dde3ea;
  --label-text-on-light: #17324d;

  --bs-body-font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
  --bs-link-color: #0078bd;
  --bs-link-color-rgb: 0, 120, 189;
  --bs-link-hover-color: #006caa;
  --bs-link-hover-color-rgb: 0, 108, 170;
  --bs-primary: #0078bd;
  --bs-primary-rgb: 0, 120, 189;
}

body {
  font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
  color: #19191a;
}

/* ---------- Testata: logo DMI + "Aulario" su blu, menu su blu ---------- */
body > div.d-flex.align-items-center.gap-2.m-2 {
  margin: 0 !important;
  padding: 10px 18px;
  gap: 16px !important;
  background-color: #0078bd;
}
body > div.d-flex.align-items-center.gap-2.m-2 img.logo {
  max-height: 58px;
  display: block;
}
body > div.d-flex.align-items-center.gap-2.m-2 > div {
  border-left: 1px solid rgba(255, 255, 255, 0.5) !important;
  padding-left: 16px !important;
}
body > div.d-flex.align-items-center.gap-2.m-2 h5,
body > div.d-flex.align-items-center.gap-2.m-2 h5 a {
  color: #ffffff !important;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
}

/* Schermi stretti (telefoni): il logo si restringe per stare nella
 * larghezza, "Aulario" va a capo sotto il logo. */
body > div.d-flex.align-items-center.gap-2.m-2 > a.navbar-brand {
  min-width: 0;
  flex-shrink: 1;
}
@media (max-width: 767.98px) {
  body > div.d-flex.align-items-center.gap-2.m-2 {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 2px 12px !important;
  }
  body > div.d-flex.align-items-center.gap-2.m-2 > a.navbar-brand {
    margin: 0;
    max-width: 100%;
  }
  body > div.d-flex.align-items-center.gap-2.m-2 img.logo {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 46px;
  }
  body > div.d-flex.align-items-center.gap-2.m-2 > div {
    border-left: 0 !important;
    padding-left: 0 !important;
    width: 100%;
  }
  body > div.d-flex.align-items-center.gap-2.m-2 h5,
  body > div.d-flex.align-items-center.gap-2.m-2 h5 a {
    font-size: 1.25rem;
  }
}

body > nav.navbar.bg-light {
  background-color: #0078bd !important;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18) !important;
}
body > nav.navbar .navbar-nav .nav-link,
body > nav.navbar .navbar-nav .nav-link.show,
body > nav.navbar .navbar-nav .nav-link:focus,
body > nav.navbar .navbar-nav > li > a.link-primary {
  color: #ffffff !important;
  font-weight: 600;
}
body > nav.navbar .dropdown-menu .dropdown-item,
body > nav.navbar .dropdown-menu a.link-primary {
  color: #19191a !important;
  font-weight: 400;
}
body > nav.navbar .dropdown-menu .dropdown-item:hover,
body > nav.navbar .dropdown-menu .dropdown-item:focus {
  color: #ffffff !important;
  background-color: #0078bd;
}
body > nav.navbar .navbar-nav .nav-link:hover {
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 4px;
}
body > nav.navbar .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.6);
}
body > nav.navbar .navbar-toggler-icon {
  filter: invert(1) brightness(2);
}

/* Piè di pagina */
footer[role="contentinfo"] {
  background-color: #30373d !important;
  border-top: 0 !important;
}
footer[role="contentinfo"] a,
footer[role="contentinfo"] .link-primary {
  color: #ffffff !important;
}

/* Pulsanti e link principali */
.btn-primary {
  --bs-btn-bg: #0078bd;
  --bs-btn-border-color: #0078bd;
  --bs-btn-hover-bg: #006caa;
  --bs-btn-hover-border-color: #006caa;
  --bs-btn-active-bg: #005a8e;
  --bs-btn-active-border-color: #005a8e;
}
.link-primary {
  color: #0078bd !important;
}

/* ---------- Pagina di accesso: il logo è bianco, gli serve il fondo blu ---------- */
#login-box .login-icon {
  background-color: #0078bd;
  border-radius: 6px;
  padding: 18px 16px;
  margin-left: -8px;
  margin-right: -8px;
}
#login-box .login-icon img {
  width: auto !important;
  max-width: 100%;
  max-height: 64px;
}

/* ---------- Griglia delle prenotazioni (calendario, vista pubblica, monitor) ----------
 * Aspetto "tondeggiante": ogni aula è una barra chiara con gli angoli
 * arrotondati, separata dalle altre da un piccolo spazio; le prenotazioni sono
 * pillole arrotondate con una striscia più scura a sinistra.
 * Solo proprietà CSS standard sulle classi della griglia (reserved, reservable,
 * restricted, pasttime, unreservable, resourcename, resdate, reslabel): se un
 * aggiornamento le cambiasse si perderebbe l'aspetto, non le funzioni.
 * Il colore delle prenotazioni lo mettono le regole delle categorie (stile in
 * linea di LibreBooking, che vince); qui c'è solo quello predefinito. */
table.reservations {
  border: 0;                /* la tabella ha border="1" nell'HTML: niente cornice */
  border-collapse: separate;
  border-spacing: 0 4px;
}
table.reservations td {
  border: 0;
  border-left: 1px solid #e1e7ed;
}
table.reservations td.resdate,
table.reservations tr.today td.resdate {
  background-color: #0078bd;
  color: #ffffff;
  font-weight: 600;
  border-left: 0;
  border-radius: 4px 0 0 4px;
}
table.reservations td.reslabel,
table.reservations tr.today td.reslabel {
  background-color: #30373d;
  color: #ffffff;
  font-weight: 600;
  border-left: 1px solid #4a535c;
}
table.reservations tr > td:last-child {
  border-radius: 0 4px 4px 0;
}
table.reservations td.resourcename {
  background-color: #eaf0f5;
  font-weight: 600;
  border-left: 0;
  border-radius: 4px 0 0 4px;
}
table.reservations td.resourcename a {
  color: #17324d;
  text-decoration: none;
}
table.reservations td.resourcename a:hover {
  color: #0078bd;
}
/* Vista per telefoni (tabella "mobile"): barra della data in blu DMI. */
#reservations .mobile .resdate {
  background-color: #0078bd;
  color: #ffffff;
}

/* Spazio libero: "prenotabile" o, per chi non può prenotare (es. senza login),
 * "ristretto". Niente fasce grigie: colore pieno quasi bianco. */
table.reservations td.reservable,
table.reservations td.restricted,
.restricted.slot,
.legend.restricted {
  background: #f5f8fb none;
  color: #17324d;
}
table.reservations td.unreservable {
  background-color: #e8edf1;
}
/* Spazi liberi già passati: un grigio un po' più scuro, così la parte di
 * giornata trascorsa si legge anche nelle aule libere (26/11/2026). */
table.reservations td.pasttime {
  background-color: #dde3ea;
}
table.reservations td.reserved {
  background-color: #d3e7f5;
  color: #17324d;
  font-weight: 600;
  border-left: 3px solid #ffffff;
  border-right: 3px solid #ffffff;
  border-radius: 4px;
  background-clip: padding-box;
  box-shadow: inset 5px 0 0 rgba(23, 50, 77, 0.30);
  padding-left: 10px;
}
table.reservations td.reserved.hilite {
  filter: brightness(0.94);
}
table.reservations td.reserved.pending {
  background-color: #fdf0d5;
  box-shadow: inset 5px 0 0 #d18b00;
}

/* Calendario e vista pubblica: qui le prenotazioni non sono celle ma riquadri
 * (div.reserved.event) disegnati sopra la griglia, con posizione e colore in
 * linea. Stesso aspetto a pillola; le passate un po' sbiadite. */
div.reserved.event {
  border: 0;
  border-radius: 4px;
  box-shadow: inset 5px 0 0 rgba(23, 50, 77, 0.30), 0 0 0 2px #ffffff;
  padding: 2px 6px 2px 11px;
  line-height: 1.25;
  font-weight: 600;
}
/* Le prenotazioni passate restano del colore pieno della categoria, così
 * coincidono con la legenda, ma passano in secondo piano: testo grigio non
 * grassetto e striscia grigia, come nel monitor (26/11/2026). */
div.reserved.event.past {
  opacity: 1;
  font-weight: 400;
  color: #4a5560 !important;
  box-shadow: inset 5px 0 0 #9aa5b1, 0 0 0 2px #ffffff;
}

/* Legenda del calendario: al posto degli stati di LibreBooking (poco utili a
 * chi guarda) la legenda delle categorie, immagine generata da
 * tema/genera_immagini.py a partire da tema/categorie.json. */
.schedule-legend > div {
  display: none !important;
}
.schedule-legend::after {
  content: '';
  display: block;
  height: 30px;
  background: url('../dmi/legenda-categorie.png') no-repeat center / contain;
}

/* ---------- Vista monitor (monitor-display.php) ----------
 * Occupa tutto lo schermo e non scorre mai: la tabella ha l'altezza dello
 * spazio rimasto e le righe se lo dividono; le etichette stanno su una riga
 * (con "…" se troppo lunghe), così nessuna riga può allungarsi.
 * Misure in vh/vw: stesso aspetto qualunque sia lo zoom del browser. */
#page-monitor-display {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2000;
  overflow: hidden;
  background-color: #ffffff;
  font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
}

/* Ingranaggio della configurazione: piccolo, nella banda blu a destra */
#page-monitor-display #monitor-display-configuration {
  position: absolute;
  top: 3vh;
  right: 0.7vw;
  z-index: 10;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}
#page-monitor-display #monitor-display-configuration > a {
  color: rgba(255, 255, 255, 0.5) !important;
  font-size: 1.6vh;
}
#page-monitor-display #configuration-options.show,
#page-monitor-display #configuration-options.collapsing {
  position: absolute;
  right: 0;
  width: 60vw;
  background: #ffffff;
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

#page-monitor-display #monitor-display-schedule {
  margin: 0 !important;
}

/* Banda: logo DMI, "Aulario", legenda delle categorie (il nome del
 * calendario, scritto dalla pagina nel titolo, è nascosto).
 * Il logo è largo 936/130 della sua altezza: a 5.6vh fa 40.3vh. */
#page-monitor-display h1#scheduleName {
  position: relative;
  height: 8vh;
  margin: 0 0 0.6vh 0;
  padding: 0;
  background-color: #0078bd;
  background-image: url('../uploads/images/custom-logo.png'), url('../dmi/legenda-categorie.png');
  background-repeat: no-repeat, no-repeat;
  background-position: 1.4vw center, right 3vw center;
  background-size: auto 5.6vh, auto 3.4vh;
  border-radius: 0 0 6px 6px;
  font-size: 0;
}
#page-monitor-display h1#scheduleName::after {
  content: 'Aulario';
  position: absolute;
  top: 1.7vh;
  left: calc(1.4vw + 40.3vh + 1.6vw);
  height: 4.6vh;
  line-height: 4.6vh;
  padding-left: 1.6vw;
  border-left: 1px solid rgba(255, 255, 255, 0.55);
  color: #ffffff;
  font-size: 4vh;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#page-monitor-display #monitor-display-schedule > div {
  padding: 0 0.6vw;
}
#page-monitor-display table.reservations {
  height: 88vh;               /* 100vh - banda (8vh) - margini - spazio per l'ora sotto la griglia */
  border-spacing: 0 0.35vh;
  font-size: 1.75vh;
  table-layout: auto;         /* la colonna delle aule si stringe sul nome più lungo (sotto) */
}
#page-monitor-display table.reservations thead td {
  position: static;
  height: 3.6vh;
  font-size: 1.6vh;
  padding: 0 0.3vw;
  white-space: nowrap;
  overflow: hidden;
}
#page-monitor-display table.reservations td {
  height: auto;
  padding: 0 0.3vw;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Colonna delle aule larga quanto il nome più lungo, solo CSS: con
 * table-layout auto, width 1% e testo su una riga (nowrap, sopra) la colonna
 * si stringe sul contenuto. Il resto va alle ore: max-width 0 sulle altre
 * celle fa sì che un titolo lungo non allarghi la sua colonna (resta
 * troncato con "…"). */
#page-monitor-display table.reservations td.resdate {
  width: 1%;
  padding-right: 0.7vw;
}
#page-monitor-display table.reservations td:not(.resourcename):not(.resdate) {
  max-width: 0;
}
#page-monitor-display table.reservations td.resourcename {
  width: 1%;
  padding-left: 0.7vw;
  padding-right: 0.7vw;
  font-size: 1.75vh;
}
#page-monitor-display table.reservations td.reserved {
  padding-left: 0.7vw;
}
#page-monitor-display table.reservations tr.slots:nth-child(even) td.resourcename {
  background-color: #dfe7ee;
}
/* Prenotazioni finite e in corso (classi messe da static/aulario-dmi.js;
 * richiesta dell'utente del 26/11/2026, proposta "D"). Le finite tengono il
 * colore della categoria (come la legenda) ma passano in secondo piano:
 * testo grigio non grassetto e striscia grigia. Il colore del testo arriva
 * in linea con !important, quindi si usa -webkit-text-fill-color, che lo
 * scavalca. Quelle in corso hanno striscia blu DMI, un contorno blu sottile
 * e il testo in grassetto (proposta "5", scelta dell'utente al posto del
 * bordo spesso; il rosso resta alla riga dell'ora). Il contorno è almeno
 * 1 px, 0,08vw sugli schermi grandi, perché non svanisca a 720p. */
#page-monitor-display table.reservations td.reserved.dmi-passato {
  font-weight: 400;
  -webkit-text-fill-color: #4a5560;
  box-shadow: inset 0.3vw 0 0 #9aa5b1;
}
#page-monitor-display table.reservations td.reserved.dmi-in-corso {
  font-weight: 700;
  box-shadow: inset 0.3vw 0 0 #0078bd, inset 0 0 0 max(1px, 0.08vw) #0078bd;
}

/* ---------- Script del tema (static/aulario-dmi.js) ----------
 * Riga dell'ora attuale e legenda con le sole categorie presenti. Se lo
 * script gira, la pagina ha la classe "dmi-js" e la legenda in immagine
 * (riserva con tutte le categorie) si nasconde. */
.dmi-js .schedule-legend::after {
  display: none;
}
.dmi-js #page-monitor-display h1#scheduleName {
  background-image: url('../uploads/images/custom-logo.png');
}

.dmi-legenda {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
  font-weight: 600;
  color: #17324d;
}
.dmi-legenda span {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}
.dmi-legenda-calendario {
  gap: 8px;
  margin-top: 4px;
}
.dmi-legenda-calendario span {
  height: 30px;
  padding: 0 14px;
  font-size: 17px;
}
/* Nella banda blu del monitor, a destra (l'ingranaggio resta più a destra) */
#page-monitor-display .dmi-legenda-monitor {
  position: absolute;
  top: 0;
  right: 3vw;
  height: 8vh;
  max-width: 50vw;
  gap: 0.6vw;
  z-index: 5;
}
#page-monitor-display .dmi-legenda-monitor span {
  height: 3.4vh;
  padding: 0 1vw;
  font-size: 2vh;
}

/* Riga dell'ora attuale (sottile), con l'ora scritta sotto l'ultima riga
 * delle aule, così non copre le etichette delle ore. */
.dmi-ora {
  position: absolute;
  z-index: 2500;              /* sopra la vista monitor (2000) */
  width: 2px;
  margin-left: -1px;
  background-color: rgba(217, 54, 79, 0.55);   /* semitrasparente: il testo sotto resta leggibile */
  pointer-events: none;
}
.dmi-ora-etichetta {
  position: absolute;
  top: 100%;
  margin-top: 2px;
  left: 1px;
  transform: translateX(-50%);
  padding: 0 5px;
  border-radius: 3px;
  background-color: #d9364f;
  color: #ffffff;
  font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}
.dmi-ora .dmi-ora-etichetta-destra {
  left: auto;
  right: 0;
  transform: none;
}
.dmi-ora-monitor {
  width: 0.12vw;
  min-width: 2px;
}
.dmi-ora-monitor .dmi-ora-etichetta {
  margin-top: 0.3vh;
  padding: 0 0.4vw;
  font-size: 1.7vh;
}
