/* ==========================================================================
   STYLE CONSTRUCTEUR (BUILDER) - VEGAPP V2.1
   ==========================================================================
   1. Structure Générale & Panneaux Latéraux
   2. Panneau de Propriétés (Gauche - Config)
   3. Panneau de Données (Droite - Formulaires)
   4. Espace de Travail (Canvas & Blocs)
   5. Banque d'Images (Miniatures)
   6. Modales & Listes (Startup, Reorder)
   7. Utilitaires & Contrôles
   ========================================================================== */

/* --- 1. STRUCTURE GÉNÉRALE ET PANNEAUX LATÉRAUX --- */

/* Panneau Gauche (Bibliothèque & Config Globale) */
.constructor-panel {
    width: 460px;
    flex-shrink: 0;
    display: none; 
    flex-direction: column;
    background-color: #ffffff;
    border-right: 1px solid #e0e0e0;
    overflow: hidden;
    height: 100%;
}

/* En-tête des onglets (Remplace l'ancien header) */
.c-tabs-header {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 0;
    flex-shrink: 0;
    overflow-x: auto;
}

.c-tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 5px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    text-align: center;
    font-family: 'Poppins', sans-serif;
}

.c-tab-btn:hover {
    color: #1B5E20;
    background-color: #f9f9f9;
}

.c-tab-btn.active {
    color: #1B5E20;
    border-bottom-color: #1B5E20;
    background-color: #f0fdf4;
}

/* Corps du panneau gauche */
.constructor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.c-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    height: 100%;
    background-color: #fff;
    animation: fadeIn 0.2s ease-out;
}

.c-tab-content.active { display: block; }


/* --- 2. PANNEAU DE PROPRIÉTÉS (GAUCHE - CONFIG) --- */

/* Groupes de contrôles */
.c-config-group { margin-bottom: 15px; padding: 0 5px; }
.c-label { font-size: 0.8rem; font-weight: 600; color: #555; display: block; margin-bottom: 4px; }
.c-row { display: flex; gap: 8px; align-items: center; }

/* Toggles & Boutons */
.constructor-panel .toggle-group { display: flex; width: 100%; gap: 0; }
.constructor-panel .toggle-btn { 
    aspect-ratio: auto !important; height: 36px !important; padding: 0 10px !important; 
    flex: 1; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; 
}

/* Accordéons Bibliothèque */
.category-header { 
    padding: 5px 15px; cursor: pointer; font-weight: 600; color: #444; 
    font-size: 0.85rem; display: flex; justify-content: space-between; 
    background: #f1f3f5; border-bottom: 1px solid #e9ecef; 
}
.category-header:hover { background: #e9ecef; }
.category-content { display: none; padding: 8px; grid-template-columns: 1fr; gap: 6px; background: #fff; }
.sidebar-category.open .category-content { display: grid; }

/* Boutons Blocs Bibliothèque */
.library-block-btn {
    display: flex; flex-direction: row; align-items: center; padding: 3px 10px;
    border: 1px solid #e0e0e0; border-radius: 6px; cursor: grab;
    text-align: left; gap: 10px; background: #f8f9fa; 
    transition: all 0.2s; user-select: none;
}
.library-block-btn:hover { 
    border-color: #386641; color: #386641; background: #e8f5e9; 
    transform: translateX(2px); box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
}
.block-icon { font-size: 1.2rem; display: flex; align-items: center; color: #666; }
.library-block-btn:hover .block-icon { color: #386641; }
.block-label { font-size: 0.8rem; font-weight: 600; }

/* Section Bibliothèque (Grille & Liste) */
.library-category { margin-bottom: 15px; }
.library-cat-title { font-size: 0.75rem; font-weight: bold; margin-bottom: 5px; text-transform: uppercase; border-bottom: 2px solid; padding-bottom: 2px; }
.library-item { border-radius: 4px; text-align: center; transition: all 0.1s; }

/* Layout des propriétés (Colonnes Bloc / Contenu) */
.props-split-container { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.props-column { display: flex; flex-direction: column; gap: 10px; }
.props-column-title {
    font-size: 0.75rem; font-weight: 700; color: #888; 
    text-transform: uppercase; border-bottom: 1px solid #eee; 
    padding-bottom: 5px; margin-bottom: 5px; margin-top:5px; 
    background-color: #f0f0f0; padding:0.5em 2em; border-radius: 5px; 
}
.prop-label { font-size: 0.8rem; font-weight: 600; color: #444; margin-bottom: 4px; display: block; }
.prop-group { margin-bottom: 15px; }
.prop-label { font-size: 0.8rem; font-weight: 600; color: #444; margin-bottom: 4px; display: block; }
.prop-row { display: flex; gap: 10px; align-items: center; }
input.prop-input { padding: 5px; border-radius: 5px; }

/* --- 3. PANNEAU DE DONNÉES (DROITE - FORMULAIRES) --- */

#blockPropertiesContent {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden !important;
    padding: 0 !important;
    scrollbar-width: none!important; 
}
.panel-scroll-area {
    scrollbar-width: none!important;
}

.constructor-data-panel {
    background-color: #ffffff;
    width: 360px !important; min-width: 360px !important; flex: 0 0 360px !important;
    display: flex; flex-direction: column;
    height: 100%;
    min-height: 0;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow-x: hidden;
    overflow-y: visible;
    overscroll-behavior: contain;
}

/* État rétracté */
.constructor-data-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    flex: 0 0 0 !important;
}

.constructor-data-panel.collapsed > *:not(.data-panel-toggle) {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
}

/* Bouton Toggle Panel */
.data-panel-toggle {
    position: absolute;
    right: 0; /* Déborde à gauche */
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 100%;
    background: #fff;
    border:none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    box-shadow: 3px 0px 0px 0px rgba(0,0,0,0.1);
    color: #666;
    transition: all 0.2s;
    outline: none;
}
.data-panel-toggle:hover { color: #1B5E20; background: #f9f9f9; }

/* En-tête Panneau Données (Intégré du JS) */
.panel-header-wrapper { flex: 0 0 auto; background: #fff; border-bottom: 1px solid #ddd; z-index: 10; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.panel-header-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
.panel-title-custom { font-size: 0.85rem; font-weight: 800; color: #1B5E20; text-transform: uppercase; letter-spacing: 0.5px; }
.panel-filter-scroll { display: flex; gap: 6px; align-items: center; padding: 8px 10px; white-space: nowrap; }
.panel-scroll-area { flex: 1; overflow-y: auto; padding: 10px 10px 60px 0; }

/* Filtres & Actions */
.filter-btn { background: #f5f5f5; border: 1px solid #ddd; border-radius: 4px; padding: 0; cursor: pointer; color: #666; display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; transition: all 0.2s; flex-shrink: 0; }
.filter-btn:hover { background: #e0e0e0; color: #333; }
.filter-btn.active { background: #e6f4ea; border-color: #1B5E20; color: #1B5E20; box-shadow: inset 0 0 0 1px #1B5E20; }
.filter-btn svg { width: 18px; height: 18px; stroke-width: 2; }
.filter-separator { width:1px; height:20px; background:#ddd; margin:0 2px; flex-shrink:0; }

.organize-btn { background: #1B5E20; color: white; border: none; border-radius: 4px; padding: 0 12px; height: 28px; font-size: 0.75rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 4px rgba(27,94,32,0.2); transition: background 0.2s; }
.organize-btn:hover { background: #144a18; }

/* Items de Liste (Formulaires) */
.data-block-item {
    padding: 0; margin-bottom: 8px; border: 1px solid #eee; border-radius: 6px; 
    background: #fff; transition: all 0.1s; 
    border-left-width: 5px; border-left-style: solid;
}
.data-block-item.selected { background: #f0fdf4; border-color: #1B5E20; } 
.data-block-item.draggable { cursor: grab; }
.data-block-item.dragging { opacity: 0.5; background: #f0fdf4; border: 1px dashed #386641; }
.data-block-item.drag-over { border-top: 2px solid #386641; }
.drag-handle { cursor: grab; color: #999; padding-right: 10px; }

.block-header-ctrl { 
    display: flex; align-items: center; justify-content: space-between; 
    background: #f9f9f9; padding: 1px 8px; border-bottom: 1px solid #eee; 
    border-radius: 4px 4px 0 0; cursor: pointer; line-height: 1; 
}
.block-header-ctrl .block-title { font-weight: 700; font-size: 0.75rem; text-transform: uppercase; margin-top: 1px; }
.block-header-ctrl svg { display: block; }

/* Highlight Survol */
.panel-highlight { background-color: #e3f2fd !important; border-left-color: #2196F3 !important; }


/* --- 4. ESPACE DE TRAVAIL (CANVAS & BLOCS) --- */

.affiche.constructor-mode { box-shadow: 0 0 0 1px #ddd inset; transition: box-shadow 0.3s; }
body.is-dragging-block .affiche.constructor-mode { box-shadow: 0 0 0 2px #386641 inset; background-color: #f0fdf4 !important; }

/* Bloc Libre */
.free-block {
    position: absolute;
    border: none;
    outline: 1px dashed transparent;
    cursor: grab;
    box-sizing: border-box;
    min-height: 20px; min-width: 20px;
    display: flex; flex-direction: column;
    touch-action: none; 
}
.free-block:hover { outline: 1px dashed rgba(56, 102, 65, 0.5); }
.free-block.selected { outline: 2px solid #386641; z-index: 1000 !important; cursor: move; }
.free-block.full-width-block { cursor: ns-resize !important; }

/* Mode Fantôme (Blocs masqués) */
.free-block.condition-hidden { opacity: 0.1 !important; filter: grayscale(100%); border: 1px dashed #999; }
.free-block.condition-hidden:hover { opacity: 0.25 !important; pointer-events: auto; border-color: #999 !important; }
.custom-block.conditional-hidden[data-id] { opacity: 0.05 !important; pointer-events: none !important; filter: grayscale(100%) !important; z-index: 0 !important; border: 1px dashed #ccc; }
body.show-ghosts .custom-block.conditional-hidden[data-id] { opacity: 0.8 !important; pointer-events: auto !important; border: 2px dashed #D32F2F !important; background: rgba(255, 255, 255, 0.9) !important; z-index: 9999 !important; cursor: pointer !important; }
body.show-ghosts .custom-block.conditional-hidden::after { content: "MASQUÉ"; position: absolute; top: -15px; left: 0; background: #D32F2F; color: white; font-size: 10px; padding: 2px 4px; font-weight: bold; pointer-events: none; border-radius: 3px; }

/* Poignées de Redimensionnement (Coins) */
.resize-handle { 
    position: absolute; width: 10px; height: 10px; background: white; 
    border: 1px solid #1B5E20; border-radius: 50%; display: none; z-index: 2000 !important; 
}
.free-block.selected .resize-handle { display: block; }
.handle-nw { top: -6px; left: -6px; cursor: nw-resize; }
.handle-ne { top: -6px; right: -6px; cursor: ne-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: se-resize; }
.handle-s  { bottom: -6px; left: 50%; margin-left: -6px; cursor: ns-resize; }

/* Poignées de Bords (Edge) */
.edge-handle { position: absolute; z-index: 1010; display: none; }
.free-block.selected .edge-handle { display: block; }
.edge-handle.handle-n { top: 0; left: 0; right: 0; height: 8px; cursor: ns-resize; }
.edge-handle.handle-s { bottom: 0; left: 6px; right: 0; height: 8px; cursor: ns-resize; }
.edge-handle.handle-e { right: 0; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.edge-handle.handle-w { left: 0; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.edge-handle::after { content: ''; position: absolute; background-color: #386641; display: none; opacity: 0.8; border-radius: 2px; box-shadow: 0 0 10px rgba(255,255,255,0.8); }
.edge-handle:hover::after { display: block; }
.edge-handle.handle-n::after { left: 0; right: 0; top: 0; height: 8px; }
.edge-handle.handle-s::after { left: 0; right: 0; bottom: 0; height: 8px; }
.edge-handle.handle-e::after { top: 0; bottom: 0; right: 0; width: 8px; }
.edge-handle.handle-w::after { top: 0; bottom: 0; left: 0; width: 8px; }

/* Poignée de Rotation */
.rotate-handle { 
    position: absolute; top: 0px; left: 50%; margin-left: -5px; 
    width: 10px; height: 10px; background: white; border: 2px solid #386641; 
    border-radius: 50%; cursor: grab; display: none; z-index: 1002; 
}
.rotate-handle::after { content: ''; position: absolute; top: 10px; left: 4px; width: 2px; height: 15px; background: #386641; }
.free-block.selected .rotate-handle { display: block; }


/* --- 5. BANQUE D'IMAGES (MINIATURES) --- */

.bank-selector-container { border: 1px solid #ddd; border-radius: 4px; background: #f9f9f9; padding: 5px; margin-top: 5px; }
.bank-mini-search { width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; font-size: 0.85rem; margin-bottom: 5px; }
.bank-mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 5px; max-height: 200px; overflow-y: auto; }

.bank-mini-item {
    aspect-ratio: 1/1; border: 2px solid transparent; border-radius: 4px; cursor: pointer;
    overflow: hidden; position: relative; background: #fff; transition: all 0.2s;
}
.bank-mini-item img { width: 100%; height: 100%; object-fit: cover; }
.bank-mini-item:hover { border-color: #999; }
.bank-mini-item.selected { border-color: #386641; box-shadow: 0 0 0 2px rgba(56, 102, 65, 0.2); }
.bank-mini-item.selected::after { content: '✓'; position: absolute; top: 2px; right: 2px; background: #386641; color: white; font-size: 10px; width: 14px; height: 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.bank-mini-item:hover::before { content: attr(title); position: absolute; bottom: 0; left: 0; width: 100%; background: rgba(0,0,0,0.7); color: white; font-size: 9px; padding: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }

.bank-cat-list { display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow-y: auto; background: #fff; border: 1px solid #eee; padding: 5px; }
.bank-cat-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; padding: 4px; cursor: pointer; }
.bank-cat-item:hover { background: #f5f5f5; }


/* --- 6. MODALES & LISTES --- */

/* Modale de réorganisation */
.reorder-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 10000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.reorder-modal { background: white; width: 450px; max-width: 95%; height: 85vh; border-radius: 8px; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0,0,0,0.2); overflow: hidden; }
.reorder-header { padding: 15px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; background: #f9f9f9; }
.reorder-list { flex: 1; overflow-y: auto; padding: 10px; background: #f0f2f5; }
.reorder-item { background: white; padding: 8px 12px; border: 1px solid #ddd; margin-bottom: 6px; border-radius: 4px; display: flex; align-items: center; justify-content: space-between; cursor: grab; user-select: none; border-left-width: 5px; border-left-style: solid; }
.reorder-item.user-visible { background: #e8f5e9; }
.reorder-item.dragging { opacity: 0.5; background: #e8f5e9; border: 2px dashed #1B5E20; }
.reorder-info { flex: 1; display: flex; flex-direction: column; font-size: 0.85rem; color: #444; }
.reorder-footer { padding: 15px; border-top: 1px solid #eee; text-align: right; background: #fff; }

/* --- 13. MODALE DE CHARGEMENT (STARTUP CARDS) --- */

.startup-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.startup-section.is-sticky {
    position: sticky;
    top: -25px;
    z-index: 1;
}

.startup-section-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: #444;
    margin: 0;
    padding-left: 10px;
    line-height: 1.2;
}

/* BARRE NOUVEAU PROJET */
.startup-new-bar {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border: 1px solid #ddd;
}

.icon-box-new {
    width: 42px; height: 42px;
    background: #e6f4ea;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #1B5E20;
}

.startup-input, .startup-select {
    padding: 0 12px;
    height: 42px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    width: 100%;
    font-family: 'Poppins', sans-serif;
}
.startup-select {
    width: 140px;
    cursor: pointer;
    background-color: #fff;
}

/* GRILLES ET CARTES */
.startup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 10px;
}

.startup-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #eee;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    position: relative;
}

.startup-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-color: #386641;
}

/* Zone Aperçu Image */
.startup-card-preview {
    width: 100%;
    aspect-ratio: 1 / 1.414; /* Ratio A4 */
    background-color: #e5e7eb;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    isolation: isolate;
}
.custom-bg-layer {
    isolation: isolate;
}
.startup-card-preview.landscape {
    aspect-ratio: 1.414 / 1;
}

.startup-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Remplit la carte */
    transition: transform 0.3s;
}

.startup-card:hover .startup-card-preview img {
    transform: scale(1.05);
}

.startup-card-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.startup-card:hover .startup-card-overlay { opacity: 1; }

.startup-card-overlay span {
    background: white; color: #333; padding: 8px 16px; border-radius: 20px; font-weight: 600; font-size: 0.9rem;
}

/* Corps de la carte */
.startup-card-body {
    padding: 12px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
}

.startup-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #333;
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
}

.startup-card-meta {
    font-size: 0.75rem;
    color: #777;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.startup-card-footer {
    margin-top: auto;
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Badges */
.status-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}
.status-published { background: #e6f4ea; color: #1B5E20; border: 1px solid #bce0fd; }
.status-hidden { background: #f5f5f5; color: #666; border: 1px solid #ddd; }
.status-public { background: #e3f2fd; color: #0d47a1; border: 1px solid #90caf9; }

.btn-delete-card {
    background: none; border: none;
    color: #ccc; cursor: pointer;
    padding: 4px; border-radius: 4px;
    transition: all 0.2s;
}
.btn-delete-card:hover {
    background: #fee2e2; color: #c5221f;
}

/* Liste "Mes Modèles" (Panel Gauche) */
.template-card { padding: 10px; border: 1px solid #eee; background: white; border-radius: 6px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 15px; margin-bottom: 8px; }
.template-card:hover { border-color: #386641; background-color: #f0fdf4; transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.active-template { background-color: #386641 !important; border-color: #1B5E20 !important; box-shadow: 0 0 0 1px #1B5E20 inset !important; color:white; }
.template-card.active-template > div > span { color:#C5C5C5!important; }


/* --- 7. UTILITAIRES & CONTRÔLES --- */

/* Sélecteur de couleurs visuel */
.color-select-wrapper { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 5px; padding: 5px 0; }
.color-dot { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 2px solid #ddd; transition: all 0.2s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.color-dot:hover { transform: scale(1.1); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.color-dot.selected { border-color: #333 !important; transform: scale(1.15); box-shadow: 0 3px 8px rgba(0,0,0,0.25); }

/* Inputs Custom */
.constructor-select { appearance: none; background-color: #fff; border: 1px solid #ccc; border-radius: 4px; padding: 6px 25px 6px 10px; font-size: 0.85rem; color: #333; width: 100%; cursor: pointer; background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23555%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 12px; transition: all 0.2s; height: 32px; }
.constructor-select:hover { border-color: #999; }
.constructor-select:focus { outline: none; border-color: #1B5E20; box-shadow: 0 0 0 2px rgba(27, 94, 32, 0.1); border-radius:6px; }

/* Toolbar Propriétés */
.tool-btn { border: none; background: #fff; width: 28px; height: 26px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #444; transition: all 0.1s; }
.tool-btn:hover { background: #f0f0f0; color: #000; }
.tool-btn.action-delete:hover { background: #fee2e2; }
.tool-btn.action-copy:hover { background: #e3f2fd; }

.sidebar-section-layout { padding: 15px;}
.sidebar-section-title { font-size: 0.7rem; font-weight: 700; color: #666; margin: 0 0 5px 0; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #eee; padding-bottom: 3px; }

.header-btn.constructor-active { background-color: #e6f4ea; color: #1B5E20; border-color: #1B5E20; }
.constructor-toolbar { background: #fdfdfd !important; border: 1px solid #386641 !important; box-shadow: 0 -2px 10px rgba(56, 102, 65, 0.1) !important; }

/* ==========================================================================
   CONSTRUCTOR HUB (V4.2 - FULLSCREEN & RATIO FIX)
   ========================================================================== */

/* --- 1. LAYOUT GÉNÉRAL --- */

.hub-view {
    width: 100%;
    height: 100%;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hub-layout {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: #f8f9fa;
}

/* --- 2. SIDEBAR --- */

.hub-sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
    height: 100%;
}

.hub-create-section {
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 10px;
}

.hub-nav-section {
    padding: 10px 0;
    /* Note : La section "Ma Bibliothèque" a un style inline flex:1 pour prendre l'espace */
}

.hub-nav-title {
    padding: 0 20px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.hub-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 500;
    border-left: 4px solid transparent;
}

.hub-nav-item:hover {
    background-color: #f5f5f5;
    color: #1B5E20;
}

.hub-nav-item.active {
    background-color: #e6f4ea;
    color: #1B5E20;
    border-left-color: #1B5E20;
    font-weight: 600;
}

/* Liste des favoris (Shortcuts) */
.hub-fav-list {
    margin-top: 10px;
    padding-left: 20px;
    border-left: 2px solid #f0f0f0;
    margin-left: 29px; /* Alignement sous l'icône */
}

.hub-fav-shortcut {
    padding: 6px 0;
    cursor: pointer;
    border-bottom: 1px dashed #eee;
    transition: all 0.2s;
}
.hub-fav-shortcut:hover .fav-name { color: #1B5E20; text-decoration: underline; }
.fav-name { font-size: 0.85rem; color: #444; font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-meta { font-size: 0.7rem; color: #999; display: block; margin-top: 2px; }

/* --- 3. ZONE PRINCIPALE & TOOLBAR --- */

.hub-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: #f8f9fa;
}

.hub-toolbar {
    height: auto;
    min-height: 80px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-wrap: wrap; /* Permet aux filtres de passer à la ligne */
    align-items: center;
    padding: 15px 30px;
    flex-shrink: 0;
    gap: 15px; /* Espacement global */
}

/* Le titre est injecté ici par JS en 1er.
   On crée un wrapper pour Recherche + Tri qui prend le reste de la ligne 1 */
.hub-tools-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1; /* Prend tout l'espace restant à droite du titre */
    min-width: 450px; /* Empêche l'écrasement sur petits écrans */
    gap: 20px;
}

.hub-search-wrapper {
    position: relative;
    width: 350px; /* Légèrement réduit pour laisser de la place */
}

.hub-search-input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #f9f9f9;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.hub-search-input:focus {
    background: #fff;
    border-color: #1B5E20;
    box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.1);
    outline: none;
}

.hub-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.hub-sort-wrapper {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.hub-sort-wrapper select {
    border: none;
    background: transparent;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    font-size: 0.9rem;
    padding-right: 20px;
    outline: none;
}

/* Ligne 2 : Les filtres prennent toute la largeur */
.hub-filters {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    width: 100%; /* Force le passage à la ligne */
    padding-top: 5px;
    order: 99; /* S'assure qu'il est en dernier */
}

.hub-chip {
    padding: 6px 14px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid #ddd;
    color: #555;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.hub-chip:hover { border-color: #1B5E20; color: #1B5E20; }
.hub-chip.active { background: #1B5E20; color: white; border-color: #1B5E20; }

/* --- 4. GRILLE & CARTES --- */

.hub-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    width: 100%;
}

.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 188px); 
    gap: 15px;
    justify-content: center; /* Centre le bloc de grille dans la page */
    padding-bottom: 40px;
}

.hub-card {
    width: 100%; 
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #eee;
    position: relative;
    height: auto; /* Force le ratio vertical */
}

.hub-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-color: #a5d6a7;
}

/* --- 5. APERÇU (ZOOM & RATIO) --- */

.hub-card-preview {
    /* Dimensions FIXES et GARANTIES */
    width: 100% !important; /* Sera donc 240px (moins les marges) */
    height: 260px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #e0e0e0;
    position: relative;
}

/* Wrapper interne */
.hub-card-preview .startup-card-preview-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    position: absolute;
    top: 0; left: 0;
}

/* FEUILLE A4 (Contenu HTML Utilisateur) */
.hub-card-preview .startup-card-preview-inner > div {
    position: relative !important;
    top: auto !important; left: auto !important;
    transform: none !important;
    
    /* ZOOM "COVER" OPTIMISÉ POUR GRILLE 160px+ 
       Garantit que la feuille couvre la carte.
       Coupe les bords si la carte est étroite.
    */
    zoom: 0.33; 
    -moz-transform: scale(0.33); /* Fallback Firefox */
    
    box-shadow: 0 0 15px rgba(0,0,0,0.15) !important;
    border: none !important;
    margin: auto;
}

/* Ajustement Paysage */
.hub-card-preview.landscape .startup-card-preview-inner > div {
    zoom: 0.24;
    -moz-transform: scale(0.24);
}

/* IMAGES (Modèles Publics / Miniatures générées) */
.hub-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- 6. ACTIONS & OVERLAY --- */

.hub-card-actions {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.2s;
    backdrop-filter: blur(2px);
    z-index: 10;
}

.hub-card:hover .hub-card-actions { opacity: 1; }

.hub-btn-primary {
    background: #1B5E20; color: white; border: none;
    padding: 8px 15px; border-radius: 30px;
    font-weight: 600; cursor: pointer; width: 120px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transform: translateY(10px); transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 0.9rem;
}

.hub-btn-secondary {
    background: white; color: #333; border: none;
    padding: 6px 15px; border-radius: 30px;
    font-weight: 600; cursor: pointer; width: 120px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transform: translateY(10px); transition: all 0.2s;
    font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}

.hub-card:hover .hub-btn-primary,
.hub-card:hover .hub-btn-secondary { transform: translateY(0); }

.hub-btn-primary:hover { background: #144a18; transform: scale(1.05) !important; }
.hub-btn-secondary:hover { background: #f0f0f0; transform: scale(1.05) !important; }

/* Favori (Coeur) */
.hub-fav-btn {
    position: absolute;
    top: 8px; right: 8px;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: white;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #ccc;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.2s;
    z-index: 11;
    font-size: 14px;
}

.hub-fav-btn:hover, .hub-fav-btn.active {
    color: #e91e63;
    transform: scale(1.1);
}

/* Infos Carte */
.hub-card-body {
    padding: 12px;
    border-top: 1px solid #f0f0f0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hub-card-title {
    font-weight: 700;
    color: #333;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.hub-card-meta {
    font-size: 0.75rem;
    color: #888;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- ADMIN SAVE MODAL (V3.0) --- */

.admin-tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    min-height: 42px;
}

.admin-tag-container input {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    flex: 1;
    min-width: 60px;
    font-size: 0.9rem;
    padding: 5px;
}

.admin-tag-chip {
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.admin-tag-remove {
    cursor: pointer;
    font-weight: bold;
    color: #1565c0;
}
.admin-tag-remove:hover { color: #d32f2f; }

.btn-admin-toolbar {
    background-color: #333; /* Dark pour Admin */
    color: white; 
    border: 1px solid #000;
    margin-right: 10px;
}
.btn-admin-toolbar:hover { background-color: #000; }

/* --- AJOUTS HUB SIDEBAR --- */
.hub-fav-list {
    margin-top: 10px;
    padding-left: 20px; /* Aligné avec le texte des items nav */
    border-left: 2px solid #f0f0f0;
    margin-left: 29px; /* Alignement visuel sous l'icône coeur */
}

.hub-fav-shortcut {
    padding: 8px 0;
    cursor: pointer;
    border-bottom: 1px dashed #eee;
    transition: all 0.2s;
}

.hub-fav-shortcut:last-child {
    border-bottom: none;
}

.hub-fav-shortcut:hover .fav-name {
    color: #1B5E20;
    text-decoration: underline;
}

.fav-name {
    font-size: 0.85rem;
    color: #444;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fav-meta {
    font-size: 0.7rem;
    color: #999;
    display: block;
    margin-top: 2px;
}
.hub-close-top {
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hub-close-top:hover {
    background-color: #f0f0f0;
    color: #d32f2f;
    transform: rotate(90deg);
}

/* Ligne contenant Filtres (gauche) et Tri (droite) */
.hub-filter-row {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Sépare gauche et droite */
    padding: 10px 30px;
    border-bottom: 1px solid #e0e0e0;
    background: #fbfbfb;
    flex-shrink: 0;
    gap: 20px;
}

/* Ajustement conteneur chips */
.hub-filters {
    /* On retire le padding/border car géré par le parent */
    padding: 0; 
    border-bottom: none;
    background: transparent;
    flex-grow: 1; /* Prend la place dispo */
    overflow-x: auto; /* Scroll si trop de tags */
}

/* Wrapper du Tri */
.hub-sort-wrapper {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.hub-sort-wrapper select {
    border: none;
    background: transparent;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    font-size: 0.9rem;
    padding-right: 20px; /* Espace pour la flèche native */
    outline: none;
}

/* --- UX CONSTRUCTEUR AVANCÉE --- */

/* 1. Surbrillance Croisée */
.block-hover-linked {
    box-shadow: 0 0 0 3px #ffeb3b, 0 0 15px rgba(255, 235, 59, 0.6) !important;
    z-index: 60000 !important;
    transition: box-shadow 0.2s;
}

.custom-context-menu {
        position: fixed;
        background: white;
        border: 1px solid #e0e0e0;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        border-radius: 8px;
        padding: 6px 0;
        z-index: 999999 !important;
        min-width: 220px;
        font-family: 'Poppins', sans-serif;
        font-size: 13px;
        color: #333;
        animation: fadeIn 0.1s ease-out;
    }
    .ctx-item {
        padding: 8px 16px;
        display: flex;
        align-items: center;
        gap: 12px;
        cursor: pointer;
        transition: background 0.1s;
        font-weight: 500;
    }
    .ctx-item:hover { background: #f5f5f5; color: #1B5E20; }
    
    /* Style spécifique pour les SVG */
    .ctx-item svg {
        width: 16px;
        height: 16px;
        stroke: #666;
        stroke-width: 2;
        transition: stroke 0.1s;
    }
    .ctx-item:hover svg { stroke: #1B5E20; }
    
    /* Cas particulier : suppression rouge */
    .ctx-item.delete:hover { background: #ffebee; color: #d32f2f; }
    .ctx-item.delete:hover svg { stroke: #d32f2f; }

    .ctx-divider { height: 1px; background: #eee; margin: 4px 0; }
    .ctx-shortcut { margin-left: auto; color: #999; font-size: 11px; font-weight: 400; }
    
    @keyframes fadeIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }

/* 3. Guides Magnétiques */
.smart-guide-line {
    position: absolute;
    background-color: #f44336; /* Rouge magnétique */
    z-index: 9999;
    pointer-events: none;
    display: none;
}
.smart-guide-line.vertical { width: 1px; height: 100vh; top: 0; }
.smart-guide-line.horizontal { height: 1px; width: 100vw; left: 0; }

/* --- SÉLECTEUR DE CATÉGORIE (V2.3) --- */
.cat-selector-wrapper {
    position: relative;
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid rgba(0,0,0,0.1);
    height: 28px;
    display: flex;
    align-items: center;
}

.cat-selector-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85rem;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-weight: 500;
}

.cat-selector-btn:hover, .cat-selector-btn.active {
    background: #f0f0f0;
    color: #1B5E20;
}

.cat-selector-btn .cat-label {
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-popup {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 5px;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border-radius: 6px;
    width: 220px;
    z-index: 5000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.1s ease-out;
}

.cat-popup.open {
    display: flex;
}

.cat-list-scroll {
    max-height: 250px;
    overflow-y: auto;
}

.cat-option {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: #333;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.1s;
}

.cat-option:hover {
    background: #f5f5f5;
    color: #1B5E20;
}

.cat-option.selected {
    background: #e6f4ea;
    color: #1B5E20;
    font-weight: 600;
}

.cat-manage-btn {
    border-top: 1px solid #eee;
    padding: 10px;
    background: #fbfbfb;
    color: #1565c0;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.cat-manage-btn:hover {
    background: #f0f8ff;
}

.cat-manage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    background: white;
    border: 1px solid #eee;
    margin-bottom: 5px;
    border-radius: 4px;
}