/* ==========================================================================
   Notes V2 - Styles back-office
   Charte PPM : vert foncé #009180, vert clair #BBE9D2, jaune #FAEF86,
                rouge #ED5E54, noir #1A333D
   ========================================================================== */

/* --- Reset wrapper ------------------------------------------------------- */
.ppm-notes-v2-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1A333D;
    margin: -6px -12px -12px; /* compense le padding .inside de la metabox */
    overflow: hidden;
    border-radius: 0 0 8px 8px;
}
.ppm-notes-v2-wrap * { box-sizing: border-box; }

/* --- HERO HEADER --------------------------------------------------------- */
.ppm-notes-v2-hero {
    position: relative;
    padding: 22px 26px;
    color: #fff;
    overflow: hidden;
}
.ppm-notes-v2-hero-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 0% 0%, rgba(187, 233, 210, 0.4) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(250, 239, 134, 0.25) 0%, transparent 40%),
        linear-gradient(135deg, #009180 0%, #007A6C 50%, #1A333D 100%);
}
.ppm-notes-v2-hero-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.06) 0%, transparent 1%),
        radial-gradient(circle at 70% 60%, rgba(255,255,255,0.06) 0%, transparent 1%),
        radial-gradient(circle at 40% 80%, rgba(255,255,255,0.04) 0%, transparent 1%);
    background-size: 80px 80px;
}
.ppm-notes-v2-hero-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.ppm-notes-v2-hero-title {
    display: flex;
    align-items: center;
    gap: 14px;
}
.ppm-notes-v2-hero-icon {
    font-size: 36px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
}
.ppm-notes-v2-hero-title h2 {
    margin: 0;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ppm-notes-v2-hero-tag {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(250, 239, 134, 0.95);
    color: #1A333D;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 4px;
    text-transform: uppercase;
}
.ppm-notes-v2-hero-title p {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.85);
}

.ppm-notes-v2-hero-stats {
    display: flex;
    gap: 18px;
}
.ppm-notes-v2-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    backdrop-filter: blur(4px);
    min-width: 72px;
}
.ppm-notes-v2-stat-num { font-size: 22px; font-weight: 700; line-height: 1; color: #fff; }
.ppm-notes-v2-stat-lbl { font-size: 11px; color: rgba(255, 255, 255, 0.85); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* --- BARRE D'ACTIONS ----------------------------------------------------- */
.ppm-notes-v2-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 26px;
    background: #fafefb;
    border-bottom: 1px solid #e3eee9;
}

/* Filtres */
.ppm-notes-v2-filters {
    display: flex;
    background: #fff;
    border: 1px solid #e3eee9;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}
.ppm-notes-v2-filter {
    background: transparent;
    border: 0;
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: #6b7c80;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.18s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.ppm-notes-v2-filter:hover { color: #007A6C; background: #f6fbf9; }
.ppm-notes-v2-filter.is-active {
    background: #009180;
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 145, 128, 0.3);
}
.ppm-notes-v2-filter-count {
    display: inline-block;
    padding: 1px 7px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.ppm-notes-v2-filter.is-active .ppm-notes-v2-filter-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* Boutons d'ajout */
.ppm-notes-v2-add-buttons { display: flex; gap: 8px; }
.ppm-notes-v2-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    text-decoration: none;
    line-height: 1.2;
}
.ppm-notes-v2-btn-primary {
    background: #009180;
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 145, 128, 0.25);
}
.ppm-notes-v2-btn-primary:hover { background: #007A6C; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0, 145, 128, 0.35); }
.ppm-notes-v2-btn-bilan {
    background: #FAEF86;
    color: #6b5e00;
    box-shadow: 0 1px 2px rgba(250, 239, 134, 0.4);
}
.ppm-notes-v2-btn-bilan:hover { background: #f5e85f; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(250, 239, 134, 0.6); }
.ppm-notes-v2-btn-ghost {
    background: transparent;
    color: #6b7c80;
    border: 1px solid #c5d6d2;
}
.ppm-notes-v2-btn-ghost:hover { background: #f6fbf9; color: #009180; border-color: #009180; }

/* --- LISTE DES NOTES ---------------------------------------------------- */
.ppm-notes-v2-list-wrap {
    padding: 18px 26px;
    background: #fafefb;
}
.ppm-notes-v2-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ppm-notes-v2-empty {
    padding: 36px 20px;
    text-align: center;
    color: #6b7c80;
    background: #fff;
    border: 1px dashed #c5d6d2;
    border-radius: 10px;
}
.ppm-notes-v2-empty-icon { font-size: 40px; opacity: 0.5; margin-bottom: 8px; }
.ppm-notes-v2-empty p { margin: 0; line-height: 1.5; }

/* Item (note) */
.ppm-notes-v2-item {
    background: #fff;
    border: 1px solid #e3eee9;
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.18s, box-shadow 0.18s;
}
.ppm-notes-v2-item:hover { border-color: #BBE9D2; box-shadow: 0 2px 6px rgba(0, 145, 128, 0.06); }
.ppm-notes-v2-item.is-open { border-color: #009180; box-shadow: 0 4px 12px rgba(0, 145, 128, 0.1); }
.ppm-notes-v2-item.is-hidden { display: none; }

.ppm-notes-v2-item-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px 4px 4px;
}
.ppm-notes-v2-item-toggle {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    color: #1A333D;
    font: inherit;
    transition: background 0.15s;
}
.ppm-notes-v2-item-toggle:hover { background: #f6fbf9; }
.ppm-notes-v2-item-toggle:focus { outline: 2px solid #009180; outline-offset: 1px; }

.ppm-notes-v2-item-icon { font-size: 18px; flex-shrink: 0; }
.ppm-notes-v2-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ppm-notes-v2-item-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #1A333D;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ppm-notes-v2-item-sub { font-size: 11.5px; color: #6b7c80; }

.ppm-notes-v2-item-type {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.ppm-notes-v2-item-type-suivi { background: #BBE9D2; color: #007A6C; }
.ppm-notes-v2-item-type-bilan { background: #FAEF86; color: #6b5e00; }

.ppm-notes-v2-item-chev {
    flex-shrink: 0;
    color: #b8c8c5;
    font-size: 18px;
    transition: transform 0.2s;
}
.ppm-notes-v2-item.is-open .ppm-notes-v2-item-chev { transform: rotate(90deg); color: #009180; }

/* Boutons icônes */
.ppm-notes-v2-item-actions { display: flex; gap: 2px; }
.ppm-notes-v2-iconbtn {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #6b7c80;
    transition: all 0.15s;
}
.ppm-notes-v2-iconbtn:hover { background: #BBE9D2; color: #007A6C; }
.ppm-notes-v2-iconbtn-danger:hover { background: #fde0dd; color: #ED5E54; }

/* Body (déplié) */
.ppm-notes-v2-item-body {
    padding: 14px 18px 16px;
    background: linear-gradient(180deg, #fafefb 0%, #fff 100%);
    border-top: 1px solid #e3eee9;
    animation: ppm-notes-v2-slide 0.25s ease-out;
}
.ppm-notes-v2-item-body[hidden] { display: none !important; }
@keyframes ppm-notes-v2-slide {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.ppm-notes-v2-item-content {
    font-size: 13px;
    line-height: 1.55;
    color: #2c4047;
    margin-bottom: 10px;
}

/* Chips meta */
.ppm-notes-v2-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0;
}
.ppm-notes-v2-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    background: #fff;
    border: 1px solid #e3eee9;
    border-radius: 999px;
    font-size: 11.5px;
    color: #2c4047;
}
.ppm-notes-v2-chip b { color: #007A6C; font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.3px; }
.ppm-notes-v2-chip-act { background: #f6fbf9; border-color: #BBE9D2; color: #007A6C; }
.ppm-notes-v2-chip-lieu { background: #fffef0; border-color: #FAEF86; color: #6b5e00; }

/* Bilan */
.ppm-notes-v2-item-bilan {
    margin-top: 10px;
    padding: 10px 14px;
    background: linear-gradient(180deg, #fffef0 0%, #fffce0 100%);
    border: 1px solid #FAEF86;
    border-radius: 8px;
}
.ppm-notes-v2-item-bilan-label {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #6b5e00;
    margin-bottom: 6px;
}
.ppm-notes-v2-bilan-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ppm-notes-v2-bilan-chip {
    display: inline-block;
    padding: 3px 10px;
    background: #fff;
    border: 1px solid #FAEF86;
    border-radius: 999px;
    font-size: 11.5px;
    color: #6b5e00;
}

/* Ressenti */
.ppm-notes-v2-item-ressenti {
    margin-top: 10px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #e3eee9;
    border-radius: 6px;
    font-size: 12.5px;
}
.ppm-notes-v2-item-ressenti p { margin: 6px 0 0; color: #2c4047; }
.ppm-notes-v2-ressenti-pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ppm-notes-v2-ressenti-ras       { background: #BBE9D2; color: #007A6C; }
.ppm-notes-v2-ressenti-vigilance { background: #ED5E54; color: #fff; }

/* --- PAGINATION --------------------------------------------------------- */
.ppm-notes-v2-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e3eee9;
}
.ppm-notes-v2-pagination[hidden] { display: none; }
.ppm-notes-v2-page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    background: #fff;
    border: 1px solid #e3eee9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    color: #6b7c80;
    transition: all 0.15s;
}
.ppm-notes-v2-page-btn:hover:not(:disabled) { background: #f6fbf9; border-color: #BBE9D2; color: #007A6C; }
.ppm-notes-v2-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ppm-notes-v2-page-btn.is-current { background: #009180; color: #fff; border-color: #009180; }
.ppm-notes-v2-page-info { font-size: 12px; color: #6b7c80; padding: 0 8px; }

/* --- FOOTER -------------------------------------------------------------- */
.ppm-notes-v2-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 26px 18px;
    background: #fafefb;
    border-top: 1px solid #e3eee9;
}
.ppm-notes-v2-reassure {
    margin: 0;
    padding: 6px 12px;
    background: #fffef0;
    border-left: 3px solid #FAEF86;
    border-radius: 4px;
    font-size: 12px;
    color: #6b5e00;
}

/* --- BANNIÈRE INJECTÉE ACF (mode V1) ----------------------------------- */
.ppm-notes-v2-acf-banner {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px 22px;
    margin: 14px 14px 22px;
    background: linear-gradient(135deg, #f6fbf9 0%, #e8f5ee 50%, #BBE9D2 100%);
    border: 2px dashed #009180;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 145, 128, 0.08);
}
.ppm-notes-v2-acf-banner.is-loading { opacity: 0.7; pointer-events: none; }

.ppm-notes-v2-acf-banner-text { flex: 1; font-size: 13px; color: #1A333D; line-height: 1.5; }
.ppm-notes-v2-acf-banner-text > strong:first-child {
    display: block;
    color: #007A6C;
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 700;
}
.ppm-notes-v2-acf-banner-text p { margin: 0 0 8px; }
.ppm-notes-v2-acf-banner-text em { color: #007A6C; font-style: italic; font-weight: 600; }

.ppm-notes-v2-count-pill {
    display: inline-block;
    padding: 3px 10px;
    background: #009180;
    color: #fff;
    border-radius: 999px;
    font-size: 13px;
    margin-right: 4px;
}

.ppm-notes-v2-acf-banner-count { font-size: 13px; }
.ppm-notes-v2-acf-banner-reassure {
    margin-top: 10px !important;
    padding: 8px 12px;
    background: #fffef0;
    border-left: 3px solid #FAEF86;
    border-radius: 4px;
    font-size: 12.5px;
}
.ppm-notes-v2-acf-banner-already {
    margin-top: 10px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #FAEF86;
    border-radius: 4px;
    font-size: 12px;
    color: #6b5e00;
}
.ppm-notes-v2-acf-banner-actions { flex-shrink: 0; display: flex; align-items: center; }

/* --- LOADER / SPINNER --------------------------------------------------- */
.ppm-notes-v2-loader {
    position: absolute;
    inset: 0;
    background: rgba(246, 251, 249, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 10px;
    z-index: 5;
}
.ppm-notes-v2-loader p { margin: 0; color: #007A6C; font-weight: 600; font-size: 14px; }
.ppm-notes-v2-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid #BBE9D2;
    border-top-color: #009180;
    border-radius: 50%;
    animation: ppm-notes-v2-spin 0.8s linear infinite;
}
@keyframes ppm-notes-v2-spin { to { transform: rotate(360deg); } }

/* --- FORMULAIRE --------------------------------------------------------- */
.ppm-notes-v2-form-wrap {
    margin: 0 26px 22px;
    padding: 20px;
    background: #fff;
    border: 2px solid #009180;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 145, 128, 0.12);
}
.ppm-notes-v2-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #BBE9D2;
}
.ppm-notes-v2-form-header h3 { margin: 0; color: #007A6C; font-size: 16px; }

.ppm-notes-v2-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.ppm-notes-v2-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}
.ppm-notes-v2-field-full { grid-column: 1 / -1; }
.ppm-notes-v2-field > span { font-weight: 600; color: #1A333D; }
.ppm-notes-v2-field input,
.ppm-notes-v2-field select,
.ppm-notes-v2-field textarea,
.ppm-notes-v2-form textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #c5d6d2;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ppm-notes-v2-field input:focus,
.ppm-notes-v2-field select:focus,
.ppm-notes-v2-field textarea:focus,
.ppm-notes-v2-form textarea:focus {
    outline: 0;
    border-color: #009180;
    box-shadow: 0 0 0 3px rgba(0, 145, 128, 0.15);
}

.ppm-notes-v2-fieldset {
    border: 1px solid #BBE9D2;
    border-radius: 8px;
    padding: 12px 16px 14px;
    margin: 0 0 12px;
    background: #f6fbf9;
}
.ppm-notes-v2-fieldset legend {
    font-weight: 700;
    color: #007A6C;
    padding: 0 6px;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.ppm-notes-v2-fieldset-bilan { border-color: #FAEF86; background: #fffef0; }
.ppm-notes-v2-fieldset-bilan legend { color: #6b5e00; }

.ppm-notes-v2-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 4px 12px;
}
.ppm-notes-v2-checkbox,
.ppm-notes-v2-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}
.ppm-notes-v2-checkbox:hover,
.ppm-notes-v2-radio:hover { background: #fff; }
.ppm-notes-v2-checkbox input,
.ppm-notes-v2-radio input { margin: 0; }

.ppm-notes-v2-radio-row { display: flex; gap: 16px; margin-bottom: 8px; }

.ppm-notes-v2-form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #BBE9D2;
}

/* --- TOAST -------------------------------------------------------------- */
.ppm-notes-v2-toast {
    position: fixed;
    top: 48px;
    right: 20px;
    padding: 12px 18px;
    background: #009180;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    z-index: 100000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    animation: ppm-notes-v2-toast-in 0.25s ease-out;
}
.ppm-notes-v2-toast-error { background: #ED5E54; }
@keyframes ppm-notes-v2-toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 800px) {
    .ppm-notes-v2-hero-content { flex-direction: column; align-items: flex-start; }
    .ppm-notes-v2-hero-stats { width: 100%; }
    .ppm-notes-v2-stat { flex: 1; }
    .ppm-notes-v2-actions-bar { flex-direction: column; align-items: stretch; }
    .ppm-notes-v2-filters { justify-content: center; }
    .ppm-notes-v2-add-buttons { justify-content: center; }
    .ppm-notes-v2-item-row { flex-wrap: wrap; }
    .ppm-notes-v2-item-toggle { flex-wrap: wrap; }
}
