/**
 * ADMIN UI - Interface d'administration intégrée
 *
 * Design:
 * - Badge admin en haut à gauche
 * - Boutons flottants en bas
 * - Modales avec backdrop blur
 * - Tout par-dessus la carte
 */

/* ============================================
   BADGE ADMIN (haut gauche)
   ============================================ */

.admin-badge {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 11px 18px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 2px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-name {
    padding-left: 5px;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.2px;
    color: #333;
}

.admin-spacer {
    padding-top: 1px;
    font-size: 10px;
    color: #333;
    font-weight: 400;
}

.admin-role {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 400;
    color: #555;
}

.connection-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    color: #888;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-btn:hover {
    background: #f5f5f5;
    color: #ff4444;
    transform: scale(1.05);
}

/* Badge de connexion - tout est cliquable */
.login-badge {
    cursor: pointer;
}

.login-badge:hover .login-btn {
    background: #f5f5f5;
    color: #000000;
    transform: scale(1.05);
}

/* ============================================
   BOUTONS AJOUTER UN PROJET
   ============================================ */

.floating-btn {
    position: fixed;
    bottom: 30px;
    padding: 3px 22px;
    border: none;
    color: #555;
    background-color: #00000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-btn:hover {
    transform: scale(1.03);
}

.floating-btn svg {
    width: 5px;
    height: 5px;
}

.add-btn {
    left: 50%;
    transform: translateX(-50%);
}

.add-btn:hover {
    transform: translateX(-50%) scale(1.03);
}

/* ============================================
   BACKDROP BLUR
   ============================================ */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

/* ============================================
   MODALES
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 40px;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: rgb(255, 255, 255);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-large {
    max-width: 1200px;
}

.modal-header {
    padding: 6px 28px;
    border-bottom: 1.5px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.2px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    font-weight: 300;
    color: #aaa;
    cursor: pointer;
    width: 27px;
    height: 27px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1;
}

.modal-close:hover {
    background: #f5f5f5;
    color: #ff0000;
    transform: scale(1.05);
}

/* ============================================
   FORMULAIRES
   ============================================ */

.modal form {
    padding: 28px 28px 20px 28px;
}

.form-section {
    margin-bottom: 28px;
}

.form-section h3 {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.3px;
    color: #333;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1.5px solid #f0f0f0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.2px;
    color: #666;
    margin-bottom: 7px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #e8e8e8;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 400;
    font-family: 'Poppins', sans-serif;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fafafa;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #949494;
    background: white;
}

.form-group input[type="color"] {
    width: 80px;
    height: 42px;
    border: 1.5px solid #e8e8e8;
    border-radius: 6px;
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group input[type="color"]:hover {
    border-color: #d0d0d0;
}

.form-group input[type="file"] {
    padding: 10px 0;
    font-size: 12px;
    font-weight: 400;
}

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.1px;
    color: #aaa;
    line-height: 1.4;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.image-preview {
    margin-top: 15px;
    border-radius: 6px;
    overflow: hidden;
    border: 1.5px solid #f0f0f0;
}

.image-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.error-message {
    background: #fff5f5;
    border: 1.5px solid #fecaca;
    color: #dc2626;
    padding: 11px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    margin-bottom: 15px;
    display: none;
}

.error-message:not(:empty) {
    display: block;
}

/* ============================================
   BOUTONS
   ============================================ */

.btn {
    padding: 3px 22px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.3px;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    color: rgb(0, 0, 0);
    background-color: hsl(0, 0%, 100%);
}

.btn-primary:hover {
    /* transform: translateY(-1px); */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.btn-secondary:hover {
    background: #e8e8e8;
    /* transform: translateY(-1px); */
}

.btn-danger {
    background: #f56565;
    color: white;
    font-weight: 400;
}

.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(245, 101, 101, 0.25);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 6px;
    border-top: 1.5px solid #f0f0f0;
    margin-top: 6px;
}

/* ============================================
   OVERLAYS PROJETS & BOUTON MODIFIER
   ============================================ */

.project-overlays-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 400;
}

.project-overlay {
    position: absolute;
    pointer-events: auto;
}

/* Les dimensions et positions sont appliquées dynamiquement via JS depuis VISUAL_STYLE */

/* Comportement par défaut sur appareil avec souris : bouton caché */
.project-overlays-container.mouse-device .project-edit-btn {
    opacity: 0;
}

/* Au hover de l'overlay, montrer le bouton */
.project-overlays-container.mouse-device .project-overlay:hover .project-edit-btn {
    opacity: 1;
}

/* Sur appareil tactile : bouton toujours visible */
.project-overlays-container.touch-device .project-edit-btn {
    opacity: 1;
}

/* Style du SVG */
.project-edit-btn svg {
    display: block;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Au hover du bouton, agrandir le SVG à l'intérieur */
.project-edit-btn:hover svg {
    transform: scale(1.2);
}

.project-edit-btn svg path {
    fill: currentColor;
}

/* ============================================
   MODAL BODY FLEX (Preview + Formulaire)
   ============================================ */

.modal-body-flex {
    display: flex;
    gap: 30px;
    padding: 0;
}

.preview-column {
    flex: 0 0 auto;
    width: 60%;
    min-width: 300px;
    display: flex;
    flex-direction: column;
}

.preview-title {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.3px;
    color: #333;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1.5px solid #f0f0f0;
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    min-height: 300px;
}

#preview-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    cursor: default;
    touch-action: none;
}

.form-column {
    flex: 1;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
    padding-right: 28px;
}

/* Ajuster le padding du formulaire car il est maintenant dans .form-column */
.form-column form {
    padding: 20px 0;
}

/* ============================================
   INPUTS VISUELS DIMENSIONS
   ============================================ */

.visual-dimensions {
    display: flex;
    gap: 20px;
    align-items: center;
    background: #fafafa;
    border: 1.5px solid #e8e8e8;
    border-radius: 6px;
    padding: 15px;
}

.dimension-inputs {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dimension-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dimension-label {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    min-width: 50px;
    margin: 0;
}

.dimension-input {
    width: 70px;
    padding: 8px 10px;
    border: 1.5px solid #e8e8e8;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    background: white;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dimension-input:focus {
    outline: none;
    border-color: #667eea;
}

.dimension-visual {
    flex: 1;
    display: flex;
    justify-content: center;
}

.dimension-svg {
    width: 100%;
    max-width: 200px;
    height: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .admin-badge {
        top: 10px;
        left: 10px;
        padding: 10px 15px;
    }

    .floating-btn {
        bottom: 20px;
    }

    .modal {
        padding: 20px;
    }

    .modal-content {
        max-height: 90vh;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal form {
        padding: 20px;
    }

    /* Layout 2 colonnes → 1 colonne sur mobile */
    .modal-body-flex {
        flex-direction: column;
        gap: 20px;
    }

    .preview-column {
        width: 100%;
        padding: 20px 20px 0 20px;
    }

    .preview-container {
        min-height: 250px;
        max-height: 350px;
    }

    .form-column {
        padding: 0 20px;
        max-height: none;
    }

    .form-column form {
        padding: 0 0 20px 0;
    }

    /* Inputs visuels de dimensions en colonne sur mobile */
    .visual-dimensions {
        flex-direction: column;
    }

    .dimension-visual {
        width: 100%;
    }
}
