/* Agenda, vista settimanale estesa: griglia con l'aspetto del foglio Google della segreteria. */

.bo-vista-switch { display: inline-flex; border: 1px solid #d0d7de; border-radius: 8px; overflow: hidden; margin-left: .25rem; }
.bo-vista-switch button { border: 0; background: #fff; color: #444; padding: .3rem .7rem; font-size: .85rem; display: inline-flex; align-items: center; gap: .35rem; }
.bo-vista-switch button + button { border-left: 1px solid #d0d7de; }
.bo-vista-switch button.attivo { background: #1e8e3e; color: #fff; }
.ags-giorno-h { cursor: pointer; }
.ags-giorno-h:hover .ags-giorno-nome { text-decoration: underline; }

.ags-main { display: flex; flex-direction: column; min-width: 0; }

.ags-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem;
    padding: .75rem 1rem; background: #1e8e3e; color: #fff; border-radius: 10px 10px 0 0;
}
.ags-titolo { display: flex; align-items: baseline; gap: .75rem; flex: 1 1 auto; }
.ags-titolo-scheda { font-size: 1.15rem; font-weight: 600; letter-spacing: .02em; }
.ags-aggiornato { font-size: .75rem; opacity: .85; }
.ags-nav { display: flex; align-items: center; gap: .4rem; }
.ags-nav .bo-week-btn, .ags-nav .bo-week-btn-today { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.ags-data { width: 9.5rem; }
.ags-azioni { display: flex; gap: .4rem; }

.ags-aiuto {
    background: #f1f8f3; border: 1px solid #cfe8d6; border-top: 0; padding: .6rem 1rem;
    font-size: .85rem; display: grid; gap: .25rem;
}
.ags-aiuto kbd { font-size: .75rem; }
.ags-legenda { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .25rem; }
.ags-leg { display: inline-flex; align-items: center; gap: .3rem; }
.ags-leg::before { content: ""; display: inline-block; width: 1.4em; height: .9em; border: 1px solid #c0c0c0; }
.ags-leg:has(i)::before { display: none; }
.ags-leg--fuori::before { background: repeating-linear-gradient(135deg, #f4f4f4 0 4px, #e6e6e6 4px 8px); }
.ags-leg--no::before { background: #cfcfcf; }

.ags-legenda-tipi { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin: .5rem 0 0; font-size: .8rem; color: #3c4043; }
.ags-leg-tipo { display: inline-flex; align-items: center; gap: .35rem; }
.ags-leg-tipo-colore { display: inline-block; width: 1.4em; height: .9em; border: 1px solid #c0c0c0; }

.ags-toast {
    margin: .5rem 0 0; padding: .5rem .9rem; border-radius: 6px; font-size: .9rem; cursor: pointer;
}
.ags-toast--errore { background: #fdecea; color: #a50e0e; border: 1px solid #f5c2c0; }
.ags-toast--avviso { background: #fef7e0; color: #7a5300; border: 1px solid #f7dc8f; }

/* ── Griglia ─────────────────────────────────────────────────────── */
.ags-wrap {
    position: relative; overflow: auto; flex: 1 1 auto; max-height: calc(100vh - 150px);
    background: #fff; border: 1px solid #dadce0; outline: none; margin-top: .5rem;
    font-family: Roboto, Arial, sans-serif;
}
.ags-wrap.ags-occupato { cursor: progress; }
.ags-caricamento { padding: 2rem; color: #5f6368; }

.ags-griglia { border-collapse: collapse; table-layout: fixed; width: max-content; min-width: 100%; }
.ags-griglia th, .ags-griglia td { border: 1px solid #e2e3e3; }

.ags-griglia thead th {
    position: sticky; top: 0; z-index: 3; background: #fff; text-align: center;
    padding: .55rem .4rem; border-bottom: 2px solid #1e8e3e; font-weight: 500;
}
.ags-giorno-h { width: 13.5rem; }
.ags-giorno-data { color: #5f6368; font-size: .9rem; }
.ags-giorno-nome { font-weight: 700; letter-spacing: .03em; }
.ags-giorno-h.ags-oggi { background: #e6f4ea; }
.ags-giorno-h.ags-chiuso .ags-giorno-nome::after { content: " · chiuso"; font-weight: 400; color: #a50e0e; font-size: .8rem; }

.ags-ora-h, .ags-ora {
    position: sticky; left: 0; z-index: 2; width: 4.2rem; background: #f8f9fa;
    text-align: center; font-weight: 400; color: #3c4043;
}
.ags-ora-h { z-index: 4; }
.ags-riga-forte .ags-ora { font-weight: 700; }
.ags-riga-forte td, .ags-riga-forte th { border-top-color: #c6c6c6; }

.ags-cella {
    height: 3.1rem; padding: .2rem .35rem; text-align: center; vertical-align: middle;
    font-size: .85rem; line-height: 1.2; text-transform: uppercase; color: #202124;
    cursor: cell; user-select: none; position: relative; overflow: hidden;
}
.ags-r1 { font-weight: 500; }
.ags-r2 { letter-spacing: .02em; }
.ags-r3 { font-size: .72rem; text-transform: none; color: inherit; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ags-segue { font-size: .75rem; opacity: .75; }
.ags-ico { font-size: .7rem; opacity: .6; margin-left: .15rem; }

.ags-cella--oggi:not(.ags-cella--piena) { background: #fbfefc; }
/* Lo sfondo per tipo di slot (Configurazione → Tipi slot → "Sfondo griglia") arriva come stile in linea. */
.ags-cella--fuori:not(.ags-cella--piena) { background: repeating-linear-gradient(135deg, #f8f8f8 0 6px, #efefef 6px 12px); }
.ags-cella--no:not(.ags-cella--piena) { background: #e8e8e8; }
.ags-cella--passata { opacity: .55; }
.ags-cella--ro { cursor: not-allowed; }
.ags-cella--blocco:not([style*="background"]) { background: #d9d9d9; color: #5f6368; font-weight: 700; }
.ags-cella--segue { border-top-color: transparent !important; }
.ags-cella--scura { color: #fff; }
.ags-cella--jolly { height: auto; font-size: .75rem; cursor: default; }
.ags-riga-jolly .ags-ora { font-size: .8rem; font-style: italic; }

/* Selezione come nel foglio: bordo blu spesso. */
.ags-cella[data-sel] { box-shadow: inset 0 0 0 2px #1a73e8; }
.ags-wrap:focus .ags-cella[data-sel] { box-shadow: inset 0 0 0 2px #1a73e8, inset 0 0 0 4px rgba(26,115,232,.15); }
.ags-cella[data-taglio] { outline: 2px dashed #1a73e8; outline-offset: -4px; }
.ags-cella.ags-bersaglio { box-shadow: inset 0 0 0 2px #1e8e3e; background: #e6f4ea !important; }
.ags-cella.ags-trascinata { opacity: .4; }

/* ── Editor, menu, avvisi (inseriti da JS dentro .ags-overlay) ───── */
.ags-overlay { position: absolute; top: 0; left: 0; width: 0; height: 0; z-index: 10; }

.ags-editor {
    position: absolute; z-index: 11; resize: none; overflow: hidden;
    padding: .3rem .4rem; border: 2px solid #1a73e8; border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25); outline: none;
    font: 500 .85rem/1.25 Roboto, Arial, sans-serif; text-transform: uppercase; background: #fff;
}

.ags-menu {
    position: fixed; z-index: 1060; min-width: 15rem; background: #fff; border-radius: 6px;
    box-shadow: 0 4px 18px rgba(0,0,0,.22); padding: .35rem 0; font-size: .875rem;
}
.ags-menu-voce {
    display: flex; align-items: center; gap: .55rem; width: 100%; border: 0; background: none;
    padding: .4rem .9rem; text-align: left; color: #202124;
}
.ags-menu-voce:hover { background: #f1f3f4; }
.ags-menu-nota { padding: .4rem .9rem; color: #5f6368; max-width: 18rem; }
.ags-menu-colori { display: flex; flex-wrap: wrap; gap: .3rem; padding: .3rem .9rem .5rem; border-bottom: 1px solid #eee; margin-bottom: .25rem; }
.ags-colore { width: 1.35rem; height: 1.35rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); padding: 0; }
.ags-colore:hover { transform: scale(1.15); }
.ags-colore--nessuno { background: linear-gradient(135deg, #fff 45%, #d93025 45% 55%, #fff 55%); }

/* Autocompletamento del paziente sotto l'editor della cella. */
.ags-sugg {
    position: fixed; z-index: 1061; background: #fff; border-radius: 6px; max-width: 26rem;
    box-shadow: 0 4px 18px rgba(0,0,0,.22); padding: .25rem 0; font-family: Roboto, Arial, sans-serif;
}
.ags-sugg-voce { padding: .35rem .75rem; cursor: pointer; }
.ags-sugg-voce:hover, .ags-sugg-voce.attivo { background: #e8f0fe; }
.ags-sugg-nome { font-weight: 500; font-size: .85rem; }
.ags-sugg-info { font-size: .75rem; color: #5f6368; }
.ags-sugg-nota { font-size: .7rem; color: #80868b; padding: .3rem .75rem .15rem; border-top: 1px solid #eee; margin-top: .15rem; }

/* Modale di conferma di ogni modifica dalla griglia. */
.ags-conferma-sfondo { position: fixed; inset: 0; z-index: 1070; background: rgba(32,33,36,.45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.ags-conferma { background: #fff; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.3); max-width: 32rem; width: 100%; padding: 1.25rem 1.4rem 1rem; font-family: Roboto, Arial, sans-serif; }
.ags-conferma-titolo { font-size: 1.05rem; font-weight: 600; color: #202124; margin-bottom: .6rem; white-space: pre-line; }
.ags-conferma-riga { font-size: .9rem; color: #3c4043; margin: .2rem 0; }
.ags-conferma-msg { margin-top: .6rem; padding: .45rem .65rem; background: #e6f4ea; color: #137333; border-radius: 6px; font-weight: 500; }
.ags-conferma-attenzione { padding: .45rem .65rem; background: #fdecea; color: #a50e0e; border-radius: 6px; }
.ags-conferma-pulsanti { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.ags-conferma-pulsanti button { border-radius: 6px; padding: .45rem 1rem; font-size: .9rem; border: 1px solid #dadce0; background: #fff; color: #3c4043; }
.ags-conferma-pulsanti .ags-conferma-si { background: #1e8e3e; border-color: #1e8e3e; color: #fff; font-weight: 600; }
.ags-conferma-pulsanti button:focus { outline: 2px solid #1a73e8; outline-offset: 2px; }

.ags-lampo {
    position: absolute; z-index: 12; transform: translateY(-110%); white-space: nowrap;
    background: #3c4043; color: #fff; font-size: .78rem; padding: .3rem .55rem; border-radius: 4px;
    pointer-events: none;
}

.ags-modal-importa { max-width: 46rem; }
.ags-importa-elenco { max-height: 40vh; overflow: auto; font-size: .8rem; margin-bottom: 1rem; }

/* ── Stampa: solo la griglia, in orizzontale ─────────────────────── */
@media print {
    @page { size: A4 landscape; margin: 8mm; }
    body:has(.ags-wrap) .bo-sidebar, body:has(.ags-wrap) .bo-tabbar, body:has(.ags-wrap) .bo-header,
    body:has(.ags-wrap) .bo-vista-switch, body:has(.ags-wrap) .bo-week-btn, body:has(.ags-wrap) .bo-week-btn-today,
    body:has(.ags-wrap) .bo-sync-google, body:has(.ags-wrap) .bo-sync-pill,
    .ags-aiuto, .ags-toast, .ags-overlay { display: none !important; }
    body:has(.ags-wrap) .bo-layout, body:has(.ags-wrap) .bo-main { display: block !important; margin: 0 !important; padding: 0 !important; }
    body:has(.ags-wrap) .bo-week-nav { display: block; padding: 0 0 4mm; font-weight: 600; }
    .ags-wrap { max-height: none !important; overflow: visible !important; border: 0; }
    .ags-griglia { width: 100%; min-width: 0; }
    .ags-griglia thead th, .ags-ora, .ags-ora-h { position: static; }
    .ags-cella { height: auto; min-height: 9mm; font-size: 8pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .ags-cella[data-sel], .ags-cella[data-taglio] { box-shadow: none; outline: 0; }
    .ags-cella--passata { opacity: 1; }
}
