/* =============================================
   RÉFÉRENCES - Formulaire + Liste
   Réutilise : --theme-color, --color-*, .media-btn,
               .mat-input, .submit-btn, .filter-select
   ============================================= */

/* ---- FORMULAIRE ---- */

#refFormContainer {
    padding: 0 10px 0;
}

#refFormContainer h3 {
    margin-bottom: 16px;
}

/* Grille 4 colonnes → tuiles identiques */
.ref-type-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}

.ref-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.75em;
    background: rgba(0,0,0,0.15);
    border: 3px solid transparent;
    transition: transform 0.1s, box-shadow 0.1s, border-color 0.15s;
    color: inherit;
    user-select: none;
}

.ref-type-btn img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.ref-type-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.ref-type-btn.active {
    border-color: var(--theme-color);
    box-shadow: 0 0 0 3px var(--theme-color), inset 0 0 6px rgba(0,0,0,0.3);
    transform: translateY(1px);
}

/* Note d'intérêt : label statique au-dessus */
.ref-grade-label {
    display: block;
    font-size: 0.85em;
    margin-bottom: 4px;
    margin-top: 8px;
}

.ref-grade-select {
    width: 100%;
    margin-bottom: 16px;
}

/* Bouton submit avec couleur du média sélectionné */
#refSubmitBtn {
    background-color: var(--btn-color, #998658);
    transition: background-color 0.2s, filter 0.15s;
}

/* Toggle ref / attente */
.ref-wait-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.rwt-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: rgba(0,0,0,0.15);
    color: inherit;
    cursor: pointer;
    font-size: 0.9em;
    transition: border-color 0.15s, background 0.15s;
}

.rwt-btn.active {
    border-color: var(--theme-color, #998658);
    background: rgba(0,0,0,0.25);
}

/* ---- LISTE ---- */

#refListContainer {
    width: 100%;
    padding: 0 5px;
    box-sizing: border-box;
}

#refListContainer h3 {
    margin: 8px 0 2px;
}

#refCount {
    font-size: 0.85em;
    margin: 10px 0 -5px 0;
}

#refMediaBar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    position: sticky;
    top: 36px;
    z-index: 10;
    background: var(--background-color);
    padding: 6px 0 4px;
    /* margin: 0 -5px; */
    padding-left: 5px;
    padding-right: 5px;
}

#refMediaBar .media-btn[data-mediaid=""] {
    background: #998658ad;
}

#refItems {
    list-style: none;
    margin: 12px 0 30px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ref-item {
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.12);
    border-radius: 8px;
    padding: 7px;
}

/* Ligne 1 : badge + [titre+étoiles] + poubelle */
.ref-top-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.ref-title-block {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ref-badge {
    font-size: 0.7em;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 10px;
    background: var(--theme-color);
    color: #fff;
    white-space: nowrap;
    text-shadow: none;
    flex-shrink: 0;
}

.ref-title {
    font-weight: bold;
    font-size: 1.2em;
}

.ref-grade {
    font-size: 1.2em;
    line-height: 1em;
    letter-spacing: 1px;
    margin: 0 0 5px;
}

.ref-left-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    flex-shrink: 0;
}

.ref-type-badge {
    font-size: 0.65em;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

.ref-type-ref, .ref-type-wait {
    background: rgba(255,255,255,0.2);
}

.ref-why {
    font-size: 0.95em;
    text-align: left;
}

.ref-duration {
    font-size: 0.8em;
    text-align: left;
    margin-top: 3px;
}

/* Ligne source+platform : uniquement si présents */
.ref-bottom-row {
    display: flex;
    gap: 8px;
    font-size: 0.8em;
    font-style: italic;
    margin: 5px 0 0 0;
}

.ref-platform {
    opacity: 0.7;
}

.ref-source {
    margin-left: auto;
}

.ref-dates-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    opacity: 0.65;
    margin-top: 4px;
    font-style: italic;
}

.ref-delete-form {
    display: contents;
}

.ref-nav-link {
    font-size: 0.85em;
    color: #7a6340;
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid #c4aa7a;
    border-radius: 6px;
    transition: background 0.15s;
}

.ref-nav-link:hover {
    background: rgba(196, 170, 122, 0.2);
}

.ref-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.ref-edit-btn {
    color: inherit;
    opacity: 0.5;
    font-size: 0.95em;
    text-decoration: none;
    transition: opacity 0.15s, color 0.15s;
}

.ref-edit-btn:hover {
    color: #4a90d9;
    opacity: 1;
}

.ref-delete-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    font-size: 0.9em;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}

.ref-delete-btn:hover {
    color: #e95e50;
    opacity: 1;
}

.ref-empty {
    text-align: center;
    padding: 30px 0;
    font-style: italic;
    opacity: 0.6;
}

/* ---- RESPONSIVE ---- */
@media (min-width: 400px) {
    #refItems {
        width: 70%;
        margin: 12px auto 30px;
    }
}

@media (max-width: 360px) {
    .ref-type-bar {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }
    .ref-type-btn {
        font-size: 1em;
        padding: 8px 2px;
    }
}
