/* Medaid Calendar - FullCalendar integration styles */

.medaid-calendar-page {
    padding: 0;
}

/* ─── Professional filter bar ─────────────────────────────── */

.medaid-prof-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 16px;
}

.prof-filter-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.prof-filter-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.prof-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}
.prof-filter-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}
.prof-filter-btn.active {
    background: #3788d8;
    color: #fff;
    border-color: #3788d8;
}
.prof-filter-btn.active .prof-color-dot {
    border: 1.5px solid #fff;
}

.prof-filter-edit-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.prof-filter-edit-toggle:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}
.prof-filter-edit-toggle.active {
    border-color: #3788d8;
    color: #2563eb;
    background: #eff6ff;
}

.prof-color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.prof-color-pickers {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 4px;
    border-top: 1px solid #f3f4f6;
}

.prof-color-picker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
    color: #6b7280;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.prof-color-picker:hover,
.prof-color-picker:focus-within {
    border-color: #9ca3af;
    background: #f9fafb;
    color: #374151;
}
.prof-color-picker.is-readonly,
.prof-color-picker.is-readonly input[type="color"] {
    cursor: default;
}
.prof-color-picker input[type="color"]:disabled {
    opacity: 1;
}
.prof-color-picker input[type="color"] {
    width: 20px;
    height: 20px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    background: none;
}
.prof-color-picker input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 1px;
}
.prof-color-picker input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}
.prof-color-picker-name {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prof-color-save-btn {
    margin-left: auto;
    white-space: nowrap;
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 6px;
    align-self: center;
}

.gcal-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    line-height: 0;
}
.gcal-dot svg {
    display: block;
    width: 12px;
    height: 12px;
}

.prof-empty-state {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.prof-visibility-editor {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid #f3f4f6;
    border-bottom: 1px solid #f3f4f6;
    padding: 8px 0;
}

.prof-visibility-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.prof-visibility-name {
    font-size: 12px;
    color: #374151;
}

.prof-visibility-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
}
.prof-visibility-toggle:hover {
    background: #f9fafb;
}
.prof-visibility-toggle.is-hidden {
    color: #9ca3af;
    background: #f3f4f6;
}

.prof-visibility-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ─── Status dot on white badge (inside calendar events) ──── */

.medaid-status-dot-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50px;
    padding: 2.5px 2.5px 2.3px 2.5px;
    margin-right: 4px;
    line-height: 1;
    vertical-align: middle;
    flex-shrink: 0;
}
.medaid-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fc .fc-event .fc-event-main {
    display: flex;
    align-items: center;
}

/* Hide FullCalendar native dot - replaced by medaid-status-dot */
.fc .fc-daygrid-dot-event .fc-daygrid-event-dot {
    display: none;
}

/* Dot-events in month view: show professional color as background */
.fc .fc-daygrid-dot-event {
    border-radius: 4px;
    padding: 2px 4px;
    color: var(--fc-event-text-color, #1f2937);
}
.fc .fc-daygrid-dot-event .fc-event-title {
    font-weight: 500;
}

/*
 * FullCalendar 6 defaults --fc-event-text-color to white. That is unreadable
 * on the light professional palette (yellow, pastels) in day / 3-day / week
 * time-grid and on all-day bars. Same default as month (#1f2937); JS in
 * calendario-app.js switches to white when the background is dark.
 * Slot min height 48px: airy timegrid rows (month view ignores this var).
 */
#medaid-fullcalendar {
    --fc-event-text-color: #1f2937;
    --fc-timegrid-slot-min-height: 48px;
}
.fc .fc-timegrid-event,
.fc .fc-timegrid-event .fc-event-main,
.fc .fc-timegrid-event .fc-event-time,
.fc .fc-timegrid-event .fc-event-title,
.fc .fc-v-event .fc-event-main,
.fc .fc-h-event,
.fc .fc-h-event .fc-event-main,
.fc .fc-h-event .fc-event-title,
.fc .fc-daygrid-block-event .fc-event-title {
    color: var(--fc-event-text-color, #1f2937);
}

/* Timegrid card: column layout, status dot out of text flow */
.fc .fc-timegrid-event .fc-event-main {
    display: block;
    position: relative;
    height: 100%;
    padding: 2px 4px;
    align-items: stretch;
}
.fc .fc-timegrid-event .medaid-status-dot-wrap {
    position: absolute;
    top: 2px;
    right: 2px;
    margin-right: 0;
    z-index: 1;
}
.fc .fc-timegrid-event .medaid-tg-event {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    height: 100%;
    padding-right: 14px;
    box-sizing: border-box;
}
.fc .fc-timegrid-event .medaid-tg-time {
    font-size: 12px;
    line-height: 1.2;
    font-weight: 600;
}
.fc .fc-timegrid-event .medaid-tg-name {
    font-size: 12px;
    line-height: 1.25;
    white-space: normal;
    /* break-word (non "anywhere"): le parole vanno a capo intere, niente colonne di lettere */
    overflow-wrap: break-word;
    word-break: normal;
    min-width: 0;
    min-height: 0;
    flex: 0 1 auto;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3; /* default, ricalcolato in JS in base all'altezza della card */
    line-clamp: 3;
}

/* Card timegrid: il testo non esce mai dalla card */
.fc .fc-timegrid-event,
.fc .fc-timegrid-event .fc-event-main,
.fc .fc-timegrid-event .fc-event-main-frame {
    overflow: hidden;
}
.fc .fc-timegrid-event .medaid-tg-time {
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Card strette (molti appuntamenti sovrapposti): solo ora di inizio + nome su riga singola */
.fc .fc-timegrid-event.medaid-tg-narrow .medaid-tg-time-end {
    display: none;
}
.fc .fc-timegrid-event.medaid-tg-narrow .fc-event-main {
    padding: 2px 3px;
}
.fc .fc-timegrid-event.medaid-tg-narrow .medaid-tg-event {
    padding-right: 0;
}
.fc .fc-timegrid-event.medaid-tg-narrow .medaid-tg-time {
    padding-right: 14px;
    font-size: 11px;
}
.fc .fc-timegrid-event.medaid-tg-narrow .medaid-tg-name {
    font-size: 11px;
}

/* Card minuscole: solo colore + pallino stato; testo nel tooltip / al click */
.fc .fc-timegrid-event.medaid-tg-tiny .medaid-tg-event {
    display: none;
}
.fc .fc-timegrid-event.medaid-tg-tiny .fc-event-main {
    padding: 2px 0;
}
.fc .fc-timegrid-event.medaid-tg-tiny .medaid-status-dot-wrap {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

/* Link "+N altri" quando si supera eventMaxStack */
.fc .fc-timegrid-more-link {
    background: #f3f4f6;
    color: #374151;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 4px;
    box-shadow: 0 0 0 1px #d1d5db;
}
.fc .fc-timegrid-more-link:hover {
    background: #e5e7eb;
}
.fc .fc-popover .fc-popover-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* Vista mese: titolo su una riga con ellissi, mai fuori dalla cella */
.fc .fc-daygrid-event {
    overflow: hidden;
    max-width: 100%;
}
.fc .fc-daygrid-event .fc-event-title,
.fc .fc-daygrid-event .fc-event-time {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fc .fc-daygrid-event .fc-event-time {
    flex-shrink: 0;
}
.fc .fc-timegrid-event .medaid-tg-assoc {
    font-weight: 600;
    white-space: nowrap;
}

/* ─── Loading overlay ─────────────────────────────────────── */

#medaid-cal-loading {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    z-index: 10;
    align-items: center;
    justify-content: center;
}
#medaid-cal-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #3788d8;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Calendar container ──────────────────────────────────── */

.medaid-calendar-container {
    position: relative;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}

/* FullCalendar overrides for Cuba theme */
.fc {
    font-family: inherit;
}
.fc .fc-toolbar-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1f2937;
}
.fc .fc-button {
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 500;
    text-transform: none;
}
.fc .fc-button-primary {
    background: #fff;
    color: #374151;
    border-color: #d1d5db;
}
.fc .fc-button-primary:hover {
    background: #f3f4f6;
    color: #111827;
    border-color: #9ca3af;
}
.fc .fc-button-primary.fc-button-active,
.fc .fc-button-primary:active {
    background: #3788d8;
    color: #fff;
    border-color: #3788d8;
}
.fc .fc-today-button {
    background: #fff;
    color: #374151;
    border-color: #d1d5db;
}
.fc .fc-today-button:hover {
    background: #f3f4f6;
}
.fc .fc-today-button:disabled {
    opacity: 0.5;
}
.fc .fc-daygrid-day.fc-day-today {
    background: #eff6ff;
}
.fc .fc-timegrid-now-indicator-line {
    border-color: #ef4444;
}
.fc .fc-timegrid-now-indicator-arrow {
    border-color: #ef4444;
}
.fc .fc-event {
    border-radius: 4px;
    border: none;
    padding: 2px 4px;
    font-size: 12px;
    cursor: pointer;
}
.fc .fc-event.fc-event-dragging {
    opacity: 0.85 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
    z-index: 5;
}
.fc .fc-event.fc-event-mirror {
    border: 2px dashed #2563eb;
    background: rgba(59,130,246,0.15);
    opacity: 0.6;
}
.fc .fc-event.fc-event-selected {
    box-shadow: 0 0 0 2px #2563eb;
}
.fc .fc-daygrid-event {
    margin-bottom: 1px;
}
.fc .fc-event:not(.fc-event-mirror) {
    cursor: grab;
}
.fc .fc-event.fc-event-dragging:not(.fc-event-mirror) {
    cursor: grabbing;
}
.fc .fc-event.fc-event-not-allowed,
.fc .fc-event.fc-event-not-allowed .fc-event-main {
    cursor: pointer !important;
}
.fc .fc-h-event .fc-event-main {
    padding: 1px 4px;
}
.fc .fc-col-header-cell {
    padding: 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
}
.fc .fc-timegrid-slot-label {
    font-size: 13px;
    color: #6b7280;
}
/* Hour lines stronger; half-hour (minor) dotted */
.fc .fc-timegrid-slot {
    border-top-color: #94a3b8;
}
.fc .fc-timegrid-slot-minor {
    border-top-style: dotted;
    border-top-color: #cbd5e1;
}
.fc .fc-scrollgrid {
    border-color: #e5e7eb;
}
.fc th, .fc td {
    border-color: #e5e7eb;
}

/* ─── Legend ───────────────────────────────────────────────── */

.medaid-calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 10px 16px;
    margin-top: 12px;
    font-size: 12px;
    color: #6b7280;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* ─── Appointment modal ───────────────────────────────────── */

.medaid-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1050;
    align-items: center;
    justify-content: center;
}
.medaid-modal-overlay.show {
    display: flex;
}
.medaid-modal-dialog {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    overflow: hidden;
}
.medaid-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.medaid-modal-header h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: #374151; }

.medaid-modal-body {
    padding: 16px 20px;
}
.apt-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.apt-detail-row {
    font-size: 13px;
    color: #374151;
}
.apt-detail-row strong {
    color: #1f2937;
}
.medaid-gcal-patient-picker {
    display: grid;
    gap: 7px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}
.medaid-gcal-patient-picker input,
.medaid-gcal-patient-picker select {
    width: 100%;
    min-width: 0;
}
.medaid-gcal-patient-message {
    color: #6b7280;
}

.medaid-modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e5e7eb;
    justify-content: flex-end;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}
.status-scheduled { background: #dbeafe; color: #1d4ed8; }
.status-confirmed { background: #e0f2fe; color: #0369a1; }
.status-visited { background: #d1fae5; color: #059669; }
.status-cancelled { background: #fee2e2; color: #dc2626; }
.status-no_show { background: #ffedd5; color: #c2410c; }
.status-recurrence { background: #ede9fe; color: #7c3aed; }

/* ─── Recurrence left border on calendar events ──────────── */

.fc .fc-event[style*="border-left: 3px solid #8b5cf6"],
.fc .fc-event[style*="border-left:3px solid #8b5cf6"] {
    border-left-width: 3px !important;
}

/* ─── Google Calendar toggle button ──────────────────────── */

.medaid-gcal-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all 0.15s ease;
}
.medaid-gcal-toggle-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}
.gcal-toggle-chevron {
    transition: transform 0.2s ease;
}
.medaid-gcal-toggle-btn.open .gcal-toggle-chevron {
    transform: rotate(180deg);
}

.medaid-gcal-collapsible {
    overflow: hidden;
}

/* ─── Google Calendar panel ───────────────────────────────── */

.medaid-gcal-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.gcal-panel-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.gcal-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}
.gcal-status-connected {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
}
.gcal-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d1d5db;
}
.gcal-status-dot.connected {
    background: #10b981;
}
.gcal-settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.gcal-settings-row label {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    margin: 0;
}
.gcal-settings-row select {
    max-width: 260px;
}
.gcal-last-sync {
    font-size: 12px;
    color: #9ca3af;
}
.gcal-error {
    font-size: 12px;
    color: #ef4444;
    background: #fef2f2;
    padding: 6px 10px;
    border-radius: 6px;
}
.gcal-actions {
    display: flex;
    gap: 8px;
}
.gcal-notice, .gcal-notice-info {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}
.gcal-notice-info {
    color: #374151;
}

/* ─── Wizard calendari collegati (multi-calendario) ───────── */

.gcal-wizard-hint {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 8px;
}
.gcal-wizard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
    max-height: 360px;
    overflow-y: auto;
}
.gcal-wizard-row {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}
.gcal-wizard-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.gcal-wizard-row-head .gcal-checkbox-label {
    margin: 0;
    font-size: 13px;
}
.gcal-wizard-row-head input[type="color"] {
    width: 34px;
    height: 28px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    flex: 0 0 auto;
}
.gcal-wizard-row-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.gcal-wizard-row-body .gcal-wz-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}
.gcal-wizard-row-body .gcal-wz-prof {
    max-width: 220px;
}
.gcal-wizard-row-body .gcal-checkbox-label {
    font-size: 12px;
    color: #374151;
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ─── Admin settings card ─────────────────────────────────── */

.medaid-gcal-admin-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.medaid-gcal-admin-card h6 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
    .medaid-prof-filter-bar {
        gap: 4px;
        padding: 8px 10px;
    }
    .prof-filter-btns {
        gap: 4px;
    }
    .prof-filter-top {
        align-items: center;
    }
    .prof-filter-btn {
        font-size: 12px;
        padding: 4px 10px;
    }
    .prof-color-pickers {
        gap: 6px;
    }
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 8px;
    }
    .fc .fc-toolbar-title {
        font-size: 1rem;
    }
    .medaid-calendar-container {
        padding: 8px;
    }
    .gcal-settings-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .medaid-modal-footer {
        flex-direction: column;
    }
    .medaid-modal-footer .btn {
        width: 100%;
        text-align: center;
    }
}


/* Shared compact booking form, displayed above all floating widgets. */
.medaid-booking-dialog { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--medaid-border, #ddd); border-radius: 16px; background: var(--medaid-white, #fff); color: var(--medaid-text, #222); box-shadow: 0 20px 70px #0004; }
.medaid-booking-dialog::backdrop { background: #1118; }
.medaid-booking-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--medaid-border, #ddd); }
.medaid-booking-dialog h2 { font-size: 18px; margin: 0; }
.medaid-booking-close { background: transparent; color: inherit; border: 0; font-size: 28px; width: 40px; height: 40px; }
.medaid-booking-feedback:not(:empty) { padding: 10px 20px; }
.medaid-booking-feedback.is-error { color: var(--medaid-danger, #b42318); white-space: pre-line; }
.medaid-booking-dialog .medaid-quick-actions-bar, .medaid-booking-dialog .medaid-ops-panel-head { display: none; }
.medaid-booking-dialog .medaid-ops-panel { border: 0; box-shadow: none; margin: 0; }
.medaid-booking-dialog .medaid-card-body { padding: 16px 20px; }
#medaid-booking-fab { position: fixed; right: 24px; bottom: 24px; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 18px; background: var(--medaid-primary, #7366ff); color: #fff; box-shadow: 0 4px 16px #0003; line-height: 0; z-index: 1030; }
#medaid-booking-fab svg { width: 28px; height: 28px; display: block; }
#medaid-booking-fab:hover { filter: brightness(1.08); }
#medaid-booking-notice:not(:empty) { padding: 10px 16px; margin-bottom: 12px; border-radius: 8px; background: var(--medaid-primary-light, #eceaff); }
/* "+" unico che segue la cella sotto il puntatore: posizione fissa calcolata in
   JS, fuori dal DOM che FullCalendar ricostruisce a ogni refresh. */
.medaid-cell-add { position: fixed; z-index: 1029; width: 26px; height: 26px; display: none; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 50%; background: var(--medaid-primary, #7366ff); color: white; line-height: 0; box-shadow: 0 2px 6px #0003; cursor: pointer; }
.medaid-cell-add.is-visible { display: flex; }
.medaid-cell-add svg { width: 16px; height: 16px; display: block; }
.medaid-cell-add:focus-visible, #medaid-booking-fab:focus-visible { outline: 3px solid var(--medaid-primary, #7366ff); outline-offset: 3px; }
@media (max-width: 575px) { .medaid-booking-dialog { max-height: calc(100dvh - 16px); } .medaid-booking-dialog .medaid-card-body { padding: 12px; } }

/* ═══ Telefono: layout ispirato all'app Google Calendar ═══════════════════
   Stesso breakpoint di isMobileCal() in calendario-app.js. Solo struttura
   (densità, gerarchia, spazi): i colori restano quelli del gestionale. */

@keyframes medaid-slide-next { from { transform: translateX(28px); opacity: .35; } to { transform: none; opacity: 1; } }
@keyframes medaid-slide-prev { from { transform: translateX(-28px); opacity: .35; } to { transform: none; opacity: 1; } }

@media (max-width: 767.98px) {
    /* Contenitore: niente cornice e padding, la griglia usa tutta la larghezza */
    .medaid-calendar-container {
        padding: 0;
        border-radius: 10px;
        overflow: hidden;
    }
    .medaid-prof-filter-bar {
        margin-bottom: 10px;
    }
    /* Filtri professionisti su una riga scorrevole */
    .prof-filter-btns {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .prof-filter-btns::-webkit-scrollbar { display: none; }
    .prof-filter-btn { flex-shrink: 0; }
    .medaid-calendar-legend {
        gap: 6px 12px;
        padding: 8px 4px;
        font-size: 11px;
    }
    .legend-dot { width: 10px; height: 10px; }

    /* Toolbar compatta: [titolo ........ ‹ Oggi ›] / [Mese|Sett.|3 Giorni|Giorno] */
    .fc .fc-toolbar.fc-header-toolbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "title nav" "views views";
        flex-direction: row;
        gap: 8px;
        margin: 0;
        padding: 10px 10px 8px;
        border-bottom: 1px solid #e5e7eb;
    }
    .fc .fc-toolbar.fc-header-toolbar > .fc-toolbar-chunk:nth-child(1) { grid-area: title; min-width: 0; }
    .fc .fc-toolbar.fc-header-toolbar > .fc-toolbar-chunk:nth-child(2) { grid-area: views; }
    .fc .fc-toolbar.fc-header-toolbar > .fc-toolbar-chunk:nth-child(3) { grid-area: nav; }
    .fc .fc-toolbar-title {
        font-size: 1.15rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .fc .fc-toolbar-title::first-letter { text-transform: uppercase; }
    .fc .fc-toolbar.fc-header-toolbar > .fc-toolbar-chunk:nth-child(2) .fc-button-group {
        display: flex;
        width: 100%;
    }
    .fc .fc-toolbar.fc-header-toolbar > .fc-toolbar-chunk:nth-child(2) .fc-button {
        flex: 1 1 0;
        padding: 6px 4px;
    }
    .fc .fc-button {
        font-size: 13px;
        padding: 5px 10px;
        min-height: 34px;
    }
    .fc .fc-prev-button,
    .fc .fc-next-button {
        padding: 5px 8px;
    }
    .fc .fc-view-harness.medaid-slide-next { animation: medaid-slide-next .22s ease-out; }
    .fc .fc-view-harness.medaid-slide-prev { animation: medaid-slide-prev .22s ease-out; }

    /* Griglia: bordi esterni via, linee interne leggere */
    .fc .fc-scrollgrid { border-left: 0; border-right: 0; border-top: 0; }
    .fc .fc-scrollgrid-section > td { border-right: 0; }
    .fc .fc-col-header-cell {
        padding: 4px 0;
        font-size: 11px;
        font-weight: 500;
        text-transform: none;
    }
    .fc .fc-col-header-cell-cushion { padding: 2px 0; color: inherit; text-decoration: none; }

    /* ── Mese ─────────────────────────────────────────────── */
    .fc .fc-daygrid-day.fc-day-today { background: transparent; }
    .fc .fc-daygrid-day-top { justify-content: center; }
    .fc .fc-daygrid-day-number {
        font-size: 12px;
        line-height: 1;
        padding: 4px 0 3px;
        min-width: 20px;
        text-align: center;
        color: #374151;
        text-decoration: none;
    }
    .fc .fc-day-today .fc-daygrid-day-number {
        color: #fff;
        background: #3788d8;
        border-radius: 999px;
        padding: 4px 5px;
        margin-top: 2px;
        font-weight: 600;
    }
    .fc .fc-daygrid-day-frame { min-height: 0; }
    .fc .fc-daygrid-day-events { margin: 0 0 1px; }
    .fc .fc-daygrid-event-harness { margin: 0 1px 2px !important; background: none !important; }
    .fc .fc-daygrid-event,
    .fc .fc-daygrid-block-event,
    .fc .fc-daygrid-dot-event {
        margin: 0 !important;
        padding: 0 2px;
        border-radius: 3px;
        font-size: 10.5px;
        line-height: 15px;
        min-height: 15px;
        border-left-width: 0;
        cursor: pointer;
    }
    .fc .fc-daygrid-event .fc-event-main {
        padding: 0;
        overflow: hidden;
    }
    .fc .medaid-mo-event {
        display: flex;
        align-items: center;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
    }
    .fc .medaid-mo-name {
        overflow: hidden;
        text-overflow: clip;
        white-space: nowrap;
        font-weight: 500;
    }
    .fc .fc-daygrid-more-link {
        display: block;
        font-size: 10px;
        font-weight: 600;
        line-height: 14px;
        padding: 0 2px;
        color: #4b5563;
        text-decoration: none;
    }
    .fc .fc-daygrid-day-bottom { margin: 0 1px; padding: 0; }

    /* Pallino di stato piccolo, in linea prima del nome */
    .fc .medaid-mo-event .medaid-status-dot-wrap,
    .fc .fc-timegrid-event .medaid-tg-name .medaid-status-dot-wrap {
        position: static;
        transform: none;
        display: inline-flex;
        padding: 1px;
        margin: 0 2px 0 0;
        vertical-align: 0;
        background: #fff;
    }
    .fc .medaid-mo-event .medaid-status-dot,
    .fc .fc-timegrid-event .medaid-tg-name .medaid-status-dot {
        width: 5px;
        height: 5px;
    }

    /* Appuntamenti cancellati: barrati e attenuati */
    .fc .fc-event.medaid-ev-status-cancelled { opacity: .55; }
    .fc .fc-event.medaid-ev-status-cancelled .medaid-mo-name,
    .fc .fc-event.medaid-ev-status-cancelled .medaid-tg-name { text-decoration: line-through; }

    /* ── Settimana / 3 Giorni / Giorno ────────────────────── */
    .fc .medaid-dh-dow {
        display: block;
        font-size: 11px;
        font-weight: 500;
        color: #6b7280;
        line-height: 1.2;
    }
    .fc .medaid-dh-num {
        display: inline-block;
        min-width: 28px;
        padding: 2px 4px;
        margin-top: 1px;
        font-size: 18px;
        font-weight: 500;
        line-height: 24px;
        color: #1f2937;
        border-radius: 999px;
    }
    .fc .medaid-dh-num.is-today {
        background: #3788d8;
        color: #fff;
    }
    .fc .fc-timegrid .fc-col-header-cell-cushion { display: block; }

    .fc .fc-timegrid-slot { height: 30px; }
    /* Ora a cavallo della linea, come nell'app; le linee non attraversano la colonna orari */
    .fc .fc-timegrid-slot-label { font-size: 10.5px; vertical-align: top; border-top-color: transparent !important; }
    .fc .fc-timegrid-slot-label-cushion { padding: 0 4px; transform: translateY(-50%); }
    .fc .fc-timegrid-slots tr:first-child .fc-timegrid-slot-label-cushion { transform: none; }
    .fc .fc-timegrid-axis-cushion { font-size: 10px; padding: 2px; }
    .fc .fc-timegrid-slot-minor { border-top-color: #eef0f3; }
    .fc .fc-timegrid-col-events { margin: 0 1px; }
    .fc .fc-timegrid-col.fc-day-today { background: transparent; }

    .fc .fc-timegrid-event {
        padding: 0;
        border-radius: 4px;
        box-shadow: 0 0 0 1px #fff;
    }
    .fc .fc-timegrid-event .fc-event-main { padding: 2px 3px; }
    .fc .fc-timegrid-event .medaid-tg-event { padding-right: 0; gap: 0; }
    .fc .fc-timegrid-event .medaid-tg-name {
        font-size: 11px;
        line-height: 13px;
        font-weight: 600;
    }
    .fc .fc-timegrid-event .medaid-tg-time {
        font-size: 10px;
        line-height: 12px;
        font-weight: 400;
        opacity: .85;
        padding-right: 0;
    }
    /* Card strette (settimana) o basse: solo il nome, a capo */
    .fc .fc-timegrid-event.medaid-tg-narrow .medaid-tg-time,
    .fc .fc-timegrid-event.medaid-tg-short .medaid-tg-time { display: none; }
    .fc .fc-timegrid-event.medaid-tg-narrow .fc-event-main { padding: 2px; }
    .fc .fc-timegrid-event.medaid-tg-narrow .medaid-tg-name {
        font-size: 10px;
        line-height: 12px;
        overflow-wrap: anywhere;
    }
    .fc .fc-timegrid-event.medaid-tg-narrow .medaid-tg-time { padding-right: 0; }
    /* Card strette: il pallino va nell'angolo in basso, il nome usa tutta la larghezza */
    .fc .fc-timegrid-event.medaid-tg-narrow .medaid-tg-name .medaid-status-dot-wrap {
        position: absolute;
        top: auto;
        left: auto;
        right: 2px;
        bottom: 2px;
        margin: 0;
    }
    .fc .fc-timegrid-more-link { font-size: 10px; padding: 1px 2px; }

    /* Giorno: intestazione allineata a sinistra come nell'app */
    .fc .fc-timeGridDay-view .fc-col-header-cell { text-align: left; }
    .fc .fc-timeGridDay-view .fc-col-header-cell-cushion { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; }

    /* Riga "tutto il giorno" come nell'app: barre sotto l'intestazione */
    .fc .fc-timegrid .fc-daygrid-body .fc-daygrid-day-events { margin: 1px 0; }
    .fc .fc-timegrid .fc-h-event { font-size: 10.5px; }
}

/* ─── Occhio "vedi tutto in chiaro" (solo administrator) ─── */

.medaid-cal-reveal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
}
.medaid-cal-reveal-btn .reveal-icon-on { display: none; }
.medaid-cal-reveal-btn.active .reveal-icon-on { display: inline; }
.medaid-cal-reveal-btn.active .reveal-icon-off { display: none; }
.medaid-cal-reveal-btn.active {
    background: #b45309;
    border-color: #b45309;
    color: #fff;
}
.medaid-cal-reveal-btn.active:hover {
    background: #92400e;
    border-color: #92400e;
    color: #fff;
}
/* Eventi visibili solo grazie alla modalità reveal (calendario non condiviso). */
.fc .fc-event.medaid-gcal-revealed {
    outline: 1px dashed #b45309;
    outline-offset: -1px;
}

/* ─── Pannello GCal in modalità supporto (/app/amministrazione) ─── */

.gcal-admin-override-note {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    margin-bottom: 10px;
}

/* ─── Medicina del Lavoro: appuntamenti raggruppati per azienda ─── */

.medaid-modal-footer:empty {
    display: none;
}
.medaid-company-icon {
    display: inline-block;
    flex: 0 0 auto;
    vertical-align: -1px;
    margin-right: 4px;
}
.fc .medaid-company-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.85);
    color: #1f2937;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    white-space: nowrap;
    flex: 0 0 auto;
}
.fc .medaid-company-ev--row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
    padding: 0 2px;
}
.fc .medaid-company-ev--row .fc-event-time {
    flex: 0 0 auto;
}
.fc .medaid-company-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.fc .fc-daygrid-dot-event.medaid-ev-company-group {
    background-color: #e0f2fe;
}

.medaid-modal-dialog--wide {
    max-width: 640px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}
.medaid-modal-dialog--wide .medaid-modal-body {
    overflow-y: auto;
}
.medaid-modal-dialog--wide .medaid-modal-header h5 {
    display: flex;
    align-items: center;
    gap: 6px;
}
.medaid-company-summary {
    margin-bottom: 12px;
}
.medaid-company-apt-list {
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}
.medaid-company-apt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid #f1f5f9;
}
.medaid-company-apt:first-child {
    border-top: 0;
}
.medaid-company-apt:hover {
    background: #f9fafb;
}
.medaid-company-apt > .medaid-company-apt-open {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
    color: inherit;
}
.medaid-company-apt .mca-time {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #1f2937;
}
.medaid-company-apt .mca-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.medaid-company-apt .mca-name {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.medaid-company-apt .mca-meta {
    font-size: 12px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.medaid-company-apt .mca-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}
.medaid-modal-footer .medaid-company-back {
    margin-right: auto;
}

@media (max-width: 767.98px) {
    .medaid-company-apt {
        flex-wrap: wrap;
    }
    .medaid-company-apt .mca-actions {
        width: 100%;
    }
    .medaid-company-apt .mca-actions .btn {
        flex: 1 1 0;
        text-align: center;
    }
    .fc .medaid-mo-event .medaid-company-icon {
        display: none;
    }
    .fc .medaid-mo-event .medaid-company-name {
        text-overflow: clip;
    }
    .fc .medaid-company-count {
        min-width: 14px;
        padding: 0 3px;
        line-height: 13px;
        font-size: 9px;
    }
}
