/* Fenetres modales (confirmation, bibliotheque media). */

.admin-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.62);
    /* No backdrop-filter: on Chromium under Linux it puts the overlay on a
       separate compositing layer whose children stop repainting, leaving
       blank bands where the tabs and search bar should be. The darker
       background below replaces what the blur was doing. */
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.admin-modal-overlay.show {
    display: flex;
    opacity: 1;
}

.admin-modal {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: calc(16px * var(--radius-scale));
    width: 90%;
    max-width: 400px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.admin-modal-overlay.show .admin-modal {
    transform: scale(1);
}

.admin-modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.admin-modal-icon {
    width: 48px;
    height: 48px;
    background: rgba(var(--danger-rgb), 0.1);
    color: var(--danger);
    border-radius: calc(50% * var(--radius-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.admin-modal-icon-info {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.admin-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.admin-modal-body {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.admin-modal-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.admin-modal-footer-single {
    grid-template-columns: 1fr;
}

.admin-modal-btn {
    padding: 0.75rem;
    border-radius: calc(10px * var(--radius-scale));
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.admin-modal-btn-cancel {
    background: var(--bg-main);
    color: var(--text-main);
}

.admin-modal-btn-cancel:hover {
    background: var(--bg-sidebar);
}

.admin-modal-btn-confirm {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.admin-modal-btn-confirm:hover {
    background: var(--danger-hover);
}

.admin-modal-btn-confirm-info {
    background: var(--primary);
    border-color: var(--primary);
}

.admin-modal-btn-confirm-info:hover {
    background: var(--primary-dark);
}

/* Bibliotheque media (modal de selection d'images) */
.media-modal {
    max-width: 900px !important;
    height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
}

.media-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.media-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.media-tabs {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.media-tab {
    padding-bottom: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.media-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.media-item {
    aspect-ratio: 1;
    /* Chrome rasterises every grid cell, on screen or not, and these are
       full-size originals shown in a thumbnail box. content-visibility
       skips the rendering work for off-screen cells; the intrinsic size
       matches the square cell so the scrollbar stays stable. */
    content-visibility: auto;
    contain-intrinsic-size: 150px 150px;

    border-radius: calc(8px * var(--radius-scale));
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    background: var(--bg-sidebar);
}

.media-item:hover {
    border-color: var(--primary);
}

.media-item.selected {
    border-color: var(--primary);
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-item .delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(var(--danger-rgb), 0.8);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: calc(4px * var(--radius-scale));
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.media-item:hover .delete-btn {
    display: flex;
}

.media-hover-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px;
    font-size: 10px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-item:hover .media-hover-name {
    opacity: 1;
}

.media-dropzone {
    border: 2px dashed var(--border);
    border-radius: calc(12px * var(--radius-scale));
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.media-dropzone:hover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.05);
}
