/*
 * Portale360 — stili componenti UI condivisi (alert banner + confirm dialog)
 * Vedi static/js/portale360_ui.js per l'API.
 */

/* ---- Alert / toast container ---- */
.p360-alert-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080; /* sopra i modal Bootstrap (1055) */
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 360px;
    max-width: calc(100vw - 2rem);
    pointer-events: none;
}

.p360-alert {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 2.25rem 0.85rem 0.9rem;
    border-radius: 0.5rem;
    background: #fff;
    border-left: 4px solid var(--p360-accent, #0d6efd);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14);
    font-family: "Poppins", sans-serif;
    font-size: 0.9rem;
    color: #212529;
    overflow: hidden;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(120%);
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.p360-alert.p360-show {
    opacity: 1;
    transform: translateX(0);
}

.p360-alert.p360-hide {
    opacity: 0;
    transform: translateX(120%);
}

.p360-alert-icon {
    flex: 0 0 auto;
    font-size: 1.15rem;
    line-height: 1.3;
    color: var(--p360-accent, #0d6efd);
}

.p360-alert-body {
    flex: 1 1 auto;
    line-height: 1.35;
    word-break: break-word;
}

.p360-alert-close {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    border: 0;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    color: #6c757d;
    cursor: pointer;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
}

.p360-alert-close:hover {
    color: #212529;
    background: rgba(0, 0, 0, 0.06);
}

/* barra di avanzamento del timeout */
.p360-alert-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: var(--p360-accent, #0d6efd);
    opacity: 0.55;
    transform-origin: left center;
    animation-name: p360-progress;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.p360-alert.p360-paused .p360-alert-progress {
    animation-play-state: paused;
}

@keyframes p360-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* varianti colore (mappate sull'accent) */
.p360-alert-success { --p360-accent: #198754; }
.p360-alert-danger  { --p360-accent: #dc3545; }
.p360-alert-warning { --p360-accent: #fd7e14; }
.p360-alert-info    { --p360-accent: #0d6efd; }

@media (max-width: 575.98px) {
    .p360-alert-container {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        width: auto;
        max-width: none;
    }
}

/* ---- Confirm dialog ---- */
.p360-confirm .modal-title {
    font-family: "Poppins", sans-serif;
    font-weight: 600;
}

.p360-confirm .modal-body {
    white-space: pre-line; /* preserva gli a-capo nei messaggi testuali */
}

.p360-confirm [data-p360-ok]:disabled {
    cursor: not-allowed;
}

/* ---- Page header card (nato in Formazione course/, ora condiviso da tutta l'app) ----
   Wrapper: <div class="card course-card shadow">. Header: partial page_header.html. */
.course-card { background-color: #ffffff; border-top: 3px solid #fd7e14; }
.course-card > .card-header { background-color: #fff3e6; }
.btn-course { background-color: #fd7e14; border-color: #fd7e14; color: #fff; font-weight: 500; }
.btn-course:hover, .btn-course:focus { background-color: #e96b02; border-color: #e96b02; color: #fff; }

/* ---- Segmented control (barra schede) ---- */
.p360-segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.3rem;
    background: #f1f3f5;
    border-radius: 0.6rem;
}

.p360-segmented .nav-link {
    color: #495057;
    border: 0;
    border-radius: 0.45rem;
    padding: 0.45rem 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.p360-segmented .nav-link:hover {
    color: #fd7e14;
    background: #fff3e6;
}

.p360-segmented .nav-link.active {
    background: #fd7e14;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(253, 126, 20, 0.4);
}

/* ---- Form: label discrete, input densi, focus brand ----
   Applicare .p360-form al wrapper del form (non al body) per non toccare
   i form dentro i dialog. */
.p360-label,
.p360-form .form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #6c757d;
    margin-bottom: 0.3rem;
}

.p360-label .asteriskField,
.p360-form .form-label .asteriskField {
    color: #dc3545;
    margin-left: 0.15rem;
}

.p360-form .form-control,
.p360-form .form-select {
    font-size: 0.925rem;
    padding: 0.45rem 0.7rem;
    border-color: #e4e7eb;
    border-radius: 0.375rem;
}

.p360-form .form-control:focus,
.p360-form .form-select:focus {
    border-color: #fd7e14;
    box-shadow: 0 0 0 0.2rem rgba(253, 126, 20, 0.18);
}

.p360-form .form-control:disabled,
.p360-form .form-select:disabled {
    background-color: #f8f9fa;
    color: #adb5bd;
    border-color: #edf0f2;
}

/* Campo sempre read-only: è un DATO, non un input rotto.
   Deve stare dopo la regola :disabled (stessa specificità). */
.p360-form .form-control.p360-readonly {
    background-color: transparent;
    border-color: transparent;
    padding-left: 0;
    font-weight: 600;
    color: #212529;
    box-shadow: none;
}

/* ---- Raggruppamento campi: titolo con riga sotto ---- */
.p360-group {
    margin-bottom: 1.5rem;
}

.p360-group-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #fd7e14;
    font-weight: 700;
    margin-bottom: 0.9rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #ffe3c7;
    display: flex;
    align-items: center;
}

/* ---- Toolbar DataTables: bottone allineato alla search ----
   Applicare a #<table>_filter (via initComplete) quando ci si appende un bottone:
   allinea verticalmente label+input+bottone e uniforma l'altezza del bottone
   a quella dell'input .form-control denso. */
.p360-filter-inline {
    /* flex e non inline-flex: il contenitore occupa tutta la colonna e
       justify-content spinge search+bottone a destra. Con inline-flex il
       `text-align: right` di .dataTables_filter non agisce sui figli flex. */
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 0;
}

/* La label "Cerca:" di DataTables è display:block e conterrebbe l'input a capo. */
.p360-filter-inline label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
    white-space: nowrap;
}

.p360-filter-inline .btn {
    padding: 0.45rem 0.7rem;
    font-size: 0.925rem;
    line-height: 1.5;
    white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   bootstrap-select dentro un modale
   Il menu a tendina viene dimensionato sull'opzione più lunga (min-width in
   linea) e sborda dal dialog. Lo si vincola alla larghezza del campo e si
   manda a capo il testo delle voci lunghe.
   --------------------------------------------------------------------------- */
.modal .bootstrap-select {
    max-width: 100%;
}

.modal .bootstrap-select .dropdown-menu {
    max-width: 100%;
    min-width: 100% !important;
}

.modal .bootstrap-select .dropdown-menu .dropdown-item,
.modal .bootstrap-select .dropdown-menu li a {
    white-space: normal;
    word-break: break-word;
}

/* Il bottone del picker non deve allargarsi con l'etichetta selezionata. */
.modal .bootstrap-select > .dropdown-toggle .filter-option-inner-inner {
    overflow: hidden;
    text-overflow: ellipsis;
}
