/* css/editor/workspace.css */

/* --- WORKSPACE & CANVAS --- */
#workspace { 
    flex: 1; 
    overflow: auto; 
    background: #f1f5f9; 
    position: relative; 
    -webkit-overflow-scrolling: touch; 
    min-height: 0; /* FIX FLEXBOX : Empêche le workspace d'exploser sa taille */
    box-sizing: border-box;
}

#pages-wrapper { 
    display: flex; flex-direction: column; align-items: center; width: 100%; 
    gap: 24px; padding: 32px 20px 100px; box-sizing: border-box; 
    min-height: 100%; transform-origin: top left; 
}

.page-wrapper-outer { display: flex; flex-direction: column; align-items: center; position: relative; width: 100%; }
.page-container { box-shadow: 0 10px 30px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.05); background: white; position: relative; flex-shrink: 0; }
.page-placeholder { display: flex; align-items: center; justify-content: center; }
canvas { outline: none; display: block; }

/* Desktop: touch-action sur canvases, Fabric gère tout */
.canvas-container, .upper-canvas, .lower-canvas { touch-action: none !important; }

/* Eléments flottants */
#replace-btn { 
    position: fixed; z-index: 9999; background: #6366f1; color: white; border: none; 
    padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; 
    display: none; align-items: center; gap: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); white-space: nowrap; 
}
#replace-btn:hover { background: #4f46e5; }

/* ── HAND MODE : désactive totalement Fabric, renvoie events au workspace ── */
#workspace.hand-mode .canvas-container,
#workspace.hand-mode .upper-canvas,
#workspace.hand-mode .lower-canvas { pointer-events: none !important; }
#workspace.hand-mode { cursor: grab; }
#workspace.hand-mode:active { cursor: grabbing; }

/* --- PAGE STRIP (Numéro de page + actions) --- */
.page-strip { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 6px 12px; background: rgba(241,245,249,0.95); border-bottom: 1px solid #e2e8f0; box-sizing: border-box; gap: 8px; }
.page-strip-num { font-size: 12px; font-weight: 700; color: #64748b; min-width: 28px; }
.page-strip-btn { display: flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer; border: none; transition: all 0.15s; }
.page-strip-del { background: #fee2e2; color: #ef4444; }
.page-strip-del:hover { background: #fecaca; }
.page-strip-ins { background: #e0e7ff; color: #4f46e5; }
.page-strip-ins:hover { background: #c7d2fe; }

/* Indicateur de zoom & Badge */
#zoom-indicator { display: none; position: fixed; top: 62px; left: 50%; transform: translateX(-50%); background: rgba(15,23,42,0.82); color: white; font-size: 13px; font-weight: 700; padding: 5px 16px; border-radius: 20px; z-index: 500; pointer-events: none; letter-spacing: 0.5px; backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.35s; }
.preview-badge { position: absolute; bottom: 8px; right: 8px; background: rgba(79,70,229,0.85); color: white; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 8px; pointer-events: none; z-index: 10; letter-spacing: 0.3px; }

/* Override Mobile */
@media (max-width: 1024px) {
    #workspace { background: #64748b; overflow: auto; overflow-x: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
    #pages-wrapper { gap: 0; padding: 0 0 140px; width: max-content; min-width: 100%; transform-origin: 0 0; }
    .page-wrapper-outer { width: 100%; }
    .page-container { margin: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.2); border-radius: 0; }
    .page-strip { display: flex !important; padding: 4px 8px; }
    .page-strip-num { font-size: 11px; }
    .page-strip-btn { padding: 3px 8px; font-size: 10px; }
    #zoom-indicator { display: flex !important; }
}