.diagram-container {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    overflow-y: auto;
    display: flex;
    align-items: start;
    justify-content: center;
}

.diagram-wrapper {
    position: relative;
    width: 100%;
}

.diagram-hover {
    position: fixed;
    background: linear-gradient(135deg, rgba(250, 248, 242, 0.95), rgba(240, 235, 220, 0.92));
    color: #4a3c2a;
    padding: 10px 18px;
    font-size: 14px;
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    z-index: 50;
    pointer-events: none;
    max-width: 300px;
    border: 1px solid rgba(180, 155, 100, 0.5);
    border-radius: 20px 4px 20px 4px;
    box-shadow: 0 2px 12px rgba(140, 120, 70, 0.15);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    animation: fadeInHover 0.4s ease forwards;
    line-height: 1.4;
    white-space: nowrap;
}

.diagram-hover::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 10px;
    right: 10px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c9a84c, transparent);
}

.diagram-hover::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 10px;
    right: 10px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c9a84c, transparent);
}

@keyframes fadeInHover {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hotspot-draft {
    position: absolute;
    border: 2px solid #28a745;
    background-color: rgba(40, 167, 69, 0.15);
    z-index: 40;
    pointer-events: none;
}

.diagram-image-container {
    position: relative;
    width: 100%;
    background: #ffffff;
}

.diagram-image {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    pointer-events: none;
}

.diagram-image svg {
    width: 100%;
    height: auto;
    display: block;
}

.diagram-image-container.diagram-edit {
    cursor: default;
}

.diagram-image-container.diagram-creating {
    cursor: crosshair;
}

.hotspot-area {
    position: absolute;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 45;
}

.hotspot-area.hotspot-edit {
    cursor: move;
}

/* Handles de redimensionnement */
.hotspot-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 2px solid #007bff;
    border-radius: 50%;
    z-index: 50;
}

.hotspot-handle-nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.hotspot-handle-ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.hotspot-handle-sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.hotspot-handle-se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

.hotspot-handle-n {
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.hotspot-handle-s {
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.hotspot-handle-w {
    top: 50%;
    left: -5px;
    transform: translateY(-50%);
    cursor: w-resize;
}

.hotspot-handle-e {
    top: 50%;
    right: -5px;
    transform: translateY(-50%);
    cursor: e-resize;
}

.hotspot-area.hotspot-edit {
    border: 3px solid #0d6efd;
    background-color: rgba(13, 110, 253, 0.18);
}

.hotspot-area.hotspot-view {
    border: 1px solid transparent;
    background-color: transparent;
    opacity: 0;
    border-radius: 50%;
    transition: opacity 0.5s ease, box-shadow 0.5s ease, background-color 0.5s ease, border-color 0.5s ease;
}

.hotspot-area.hotspot-view .hotspot-label {
    display: none;
}

.hotspot-area.hotspot-view:hover {
    opacity: 1;
    background: radial-gradient(ellipse at center, rgba(201, 168, 76, 0.06) 0%, transparent 70%);
    border-color: rgba(201, 168, 76, 0.25);
    box-shadow: 0 0 16px 4px rgba(201, 168, 76, 0.12),
                inset 0 0 10px 3px rgba(201, 168, 76, 0.05);
}

.hotspot-area.hotspot-view:hover .hotspot-label {
    display: none;
}

.hotspot-area.hotspot-edit:hover {
    background-color: rgba(0, 123, 255, 0.3);
    border-color: #0056b3;
}

/* Mobile: make hotspots visible (no hover on touch devices) */
@media (max-width: 768px) {
    .hotspot-area.hotspot-view {
        opacity: 1;
        border: 1.5px dashed rgba(201, 168, 76, 0.45);
        background: radial-gradient(ellipse at center, rgba(201, 168, 76, 0.08) 0%, transparent 70%);
    }
}

.hotspot-label {
    background: #007bff;
    color: white;
    padding: 2px 6px;
    font-size: 12px;
    border-radius: 3px;
    position: absolute;
    top: -25px;
    left: 0;
}

.overlay-pad-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.overlay-pad-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(20, 18, 12, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.overlay-pad-content {
    position: fixed;
    width: 480px;
    max-width: 85vw;
    max-height: 80vh;
    overflow: hidden;
    z-index: 1001;
    transform-origin: center center;
    transform: translate(-50%, 0);
    background: linear-gradient(160deg, rgba(252, 250, 245, 0.97) 0%, rgba(245, 240, 228, 0.95) 100%);
    border: 1px solid rgba(180, 155, 100, 0.4);
    border-radius: 24px 6px 24px 6px;
    box-shadow:
        0 0 0 1px rgba(201, 168, 76, 0.15),
        0 4px 24px rgba(100, 80, 40, 0.18),
        0 12px 48px rgba(80, 60, 30, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: artNouveauUnfurl 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.overlay-pad-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    right: 20px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #c9a84c 30%, #c9a84c 70%, transparent);
    border-radius: 0 0 2px 2px;
    opacity: 0.6;
}

.overlay-pad-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20px;
    right: 20px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #c9a84c 30%, #c9a84c 70%, transparent);
    border-radius: 2px 2px 0 0;
    opacity: 0.6;
}

@keyframes artNouveauUnfurl {
    0% {
        transform: translate(-50%, 0) scale(0.3, 0.01);
        opacity: 0;
        border-radius: 50%;
    }
    30% {
        opacity: 1;
        border-radius: 30px 10px 30px 10px;
    }
    60% {
        transform: translate(-50%, 0) scale(1.02, 1.03);
    }
    80% {
        transform: translate(-50%, 0) scale(0.99, 0.99);
    }
    100% {
        transform: translate(-50%, 0) scale(1, 1);
        opacity: 1;
        border-radius: 24px 6px 24px 6px;
    }
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px 14px;
    border-bottom: 1px solid rgba(180, 155, 100, 0.3);
    background: transparent;
    position: relative;
}

.overlay-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 22px;
    right: 22px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c9a84c 20%, #c9a84c 80%, transparent);
    opacity: 0.4;
}

.overlay-header h3 {
    margin: 0;
    color: #5a4a30;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.15em;
    font-weight: normal;
    letter-spacing: 0.03em;
}

.overlay-header .close-btn {
    color: #b49b5c;
    font-size: 22px;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.25s, color 0.25s;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.overlay-header .close-btn:hover {
    opacity: 1;
    color: #8b6914;
    background: rgba(201, 168, 76, 0.1);
}

.overlay-body {
    padding: 20px 22px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
    color: #4a3c2a;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.95em;
    line-height: 1.6;
}

.overlay-intro {
    margin-bottom: 16px;
    white-space: pre-wrap;
    color: #5a4a30;
}

.overlay-intro p {
    margin: 0;
}

.overlay-images {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.overlay-images .overlay-image {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    border: 1px solid rgba(180, 155, 100, 0.3);
    border-radius: 12px 3px 12px 3px;
}

.overlay-html {
    margin-bottom: 16px;
}

.overlay-redirections {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(180, 155, 100, 0.2);
    position: relative;
}

.overlay-redirections::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(201, 168, 76, 0.3), transparent);
}

.btn-redirect {
    display: block;
    width: 100%;
    padding: 10px 18px;
    background: transparent;
    color: #5a4a30;
    border: 1px solid rgba(180, 155, 100, 0.35);
    border-radius: 16px 4px 16px 4px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.9em;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-redirect::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(201, 168, 76, 0) 0%, rgba(201, 168, 76, 0.08) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-redirect:hover {
    border-color: rgba(201, 168, 76, 0.6);
    box-shadow: 0 2px 12px rgba(201, 168, 76, 0.12);
    color: #3a2e1e;
}

.btn-redirect:hover::before {
    opacity: 1;
}

.btn-redirect-external {
    border-left: 3px solid rgba(122, 158, 126, 0.5);
}

.btn-redirect-external:hover {
    border-left-color: rgba(122, 158, 126, 0.8);
}

.overlay-admin-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(180, 155, 100, 0.15);
}

/* Mobile: center overlay popup in viewport */
@media (max-width: 768px) {
    .overlay-pad-content {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 94vw;
        max-width: 94vw;
        max-height: 85vh;
        animation: artNouveauUnfurlMobile 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    }

    .overlay-body {
        max-height: calc(85vh - 60px);
    }

    @keyframes artNouveauUnfurlMobile {
        0% {
            transform: translate(-50%, -50%) scale(0.3, 0.01);
            opacity: 0;
            border-radius: 50%;
        }
        30% {
            opacity: 1;
            border-radius: 30px 10px 30px 10px;
        }
        60% {
            transform: translate(-50%, -50%) scale(1.02, 1.03);
        }
        80% {
            transform: translate(-50%, -50%) scale(0.99, 0.99);
        }
        100% {
            transform: translate(-50%, -50%) scale(1, 1);
            opacity: 1;
            border-radius: 24px 6px 24px 6px;
        }
    }
}

/* Mode plein écran pour l'édition de diagramme */
.fullscreen-edit-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.fullscreen-edit-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 10px;
}

/* Pad de configuration en overlay */
.config-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.config-panel-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.config-panel-content {
    position: relative;
    width: 600px;
    max-width: 90vw;
    max-height: 90vh;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 10002;
    display: flex;
    flex-direction: column;
}

.config-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.config-panel-header h4 {
    margin: 0;
}

.config-panel-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.overlay-image {
    max-width: 150px;
    max-height: 150px;
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.html-editor {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    resize: vertical;
}

.main-layout {
    width: 100%;
}

.main-content {
    padding: 20px;
}

.close-btn {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 22px;
    cursor: pointer;
}
