/* ── DashScreen Admin — custom CSS ── */

/* Scrollbar discrète */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ── IDE Layout Editor ─────────────────────────────────── */

#ide-layout {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

#ide-left {
    width: 260px;
    min-width: 200px;
    background: #1e293b;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #334155;
    overflow: hidden;
    position: relative; /* ancrage pour #control-list en absolu */
}

#ide-right {
    width: 300px;
    min-width: 240px;
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0f172a;
    background-image: radial-gradient(circle at 1px 1px, #1e293b 1px, transparent 0);
    background-size: 24px 24px;
}

/* ── Barre d'alignement ── */
.align-bar {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20000;
    display: flex;
    align-items: center;
    gap: 2px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 4px 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.align-bar.hidden { display: none; }
.align-bar-label {
    font-size: 11px;
    color: #64748b;
    margin-right: 4px;
    white-space: nowrap;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.align-btn {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 5px;
    background: transparent;
    color: #94a3b8;
    border: none;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.align-btn:hover { background: #334155; color: #e2e8f0; }
.align-btn svg { width: 16px; height: 16px; }
.align-sep {
    width: 1px; height: 20px;
    background: #334155;
    margin: 0 4px;
}
/* Boutons distribuer grisés si < 3 éléments */
.align-btn.align-distrib:disabled { opacity: .3; cursor: not-allowed; }
.align-btn.align-distrib:disabled:hover { background: transparent; color: #94a3b8; }

#stage {
    position: absolute;
    box-shadow: 0 0 0 1px #334155, 0 20px 60px rgba(0,0,0,.6);
}

/* Controls on the IDE canvas */
.ide-control {
    position: absolute;
    border: 2px solid;
    cursor: move;
    box-sizing: border-box;
    user-select: none;
    overflow: hidden;
    transition: outline 0.1s;
}
/* Tout le contenu interne est non-interactif — seul .ide-control et ses poignées reçoivent les events */
.ide-control > *:not(.ide-resize-handle) {
    pointer-events: none;
}
.ide-control:hover { filter: brightness(1.1); }
.ide-control.selected {
    outline: 2px solid #fff;
    outline-offset: 2px;
    z-index: 9999 !important;
    overflow: visible;
}
.ide-control.selected-multi {
    outline: 2px solid #a5b4fc;
    outline-offset: 2px;
    z-index: 9998 !important;
}

/* Poignées de redimensionnement — visibles uniquement sur .selected */
.ide-resize-handle {
    position: absolute;
    width: 10px; height: 10px;
    background: #fff;
    border: 2px solid #6366f1;
    border-radius: 2px;
    z-index: 10000;
    box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.ide-resize-handle[data-dir="nw"] { top:-5px;  left:-5px;  cursor:nw-resize; }
.ide-resize-handle[data-dir="n"]  { top:-5px;  left:calc(50% - 5px); cursor:n-resize; }
.ide-resize-handle[data-dir="ne"] { top:-5px;  right:-5px; cursor:ne-resize; }
.ide-resize-handle[data-dir="e"]  { top:calc(50% - 5px); right:-5px; cursor:e-resize; }
.ide-resize-handle[data-dir="se"] { bottom:-5px; right:-5px; cursor:se-resize; }
.ide-resize-handle[data-dir="s"]  { bottom:-5px; left:calc(50% - 5px); cursor:s-resize; }
.ide-resize-handle[data-dir="sw"] { bottom:-5px; left:-5px; cursor:sw-resize; }
.ide-resize-handle[data-dir="w"]  { top:calc(50% - 5px); left:-5px; cursor:w-resize; }

.ide-control-badge {
    position: absolute;
    top: 0; left: 0;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    padding: 2px 5px;
    color: #fff;
    border-radius: 0 0 4px 0;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    pointer-events: none;
}
.ide-control-name {
    position: absolute;
    bottom: 3px; left: 6px; right: 6px;
    font-size: 10px;
    color: rgba(255,255,255,.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

/* Left panel — control list :
   absolu pour contourner le bug Safari (flex-1 + overflow-y:auto → height:0) */
#control-list {
    position: absolute;
    top: 45px;   /* hauteur du header (py-2.5 × 2 + ligne texte + border) */
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: auto;
}
.control-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid #1e293b;
    transition: background .15s;
}
.control-list-item:hover { background: #334155; }
.control-list-item.active       { background: #4f46e5; }
.control-list-item.active-multi { background: #312e81; }
.control-list-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.control-list-type {
    color: #94a3b8;
    font-size: 10px;
    width: 70px;
    flex-shrink: 0;
}
.control-list-name { color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Inspector panel */
#inspector-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-size: 12px;
}
.inspector-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}
.inspector-section:last-child { border-bottom: none; }
.inspector-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
    margin-bottom: 8px;
}
#inspector-content label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: #475569;
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 7px;
}
#inspector-content input[type=text],
#inspector-content input[type=number],
#inspector-content input[type=time],
#inspector-content input[type=password],
#inspector-content select,
#inspector-content textarea {
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px 7px;
    font-size: 12px;
    color: #1e293b;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
    outline: none;
    transition: border-color .15s;
}
#inspector-content input:focus,
#inspector-content select:focus,
#inspector-content textarea:focus { border-color: #6366f1; }
#inspector-content textarea { resize: vertical; min-height: 56px; }
#inspector-content input[type=color] {
    width: 100%; height: 30px; padding: 1px; border-radius: 4px; cursor: pointer;
}
.inspector-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.inspector-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.inspector-row4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; }
label.checkbox {
    flex-direction: row !important;
    align-items: center;
    gap: 6px !important;
    margin-bottom: 0 !important;
    cursor: pointer;
}
label.checkbox input[type=checkbox] { width: auto; }

/* Widget picker modal */
#widget-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 50000;
    display: flex; align-items: center; justify-content: center;
}
#widget-modal.hidden { display: none; }
#widget-modal-box {
    background: #1e293b;
    border-radius: 12px;
    padding: 24px;
    width: 560px;
    max-width: 95vw;
    box-shadow: 0 25px 50px rgba(0,0,0,.5);
}
#widget-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 16px;
}
.widget-pick-btn {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 12px 6px;
    background: #0f172a;
    border: 2px solid;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 11px;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.widget-pick-btn:hover { background: #1e293b; transform: scale(1.04); }
.widget-pick-icon { font-size: 20px; line-height: 1; }

/* Toast notification */
#toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 10px 20px; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    transform: translateY(80px); opacity: 0;
    transition: transform .3s, opacity .3s;
    z-index: 99999;
    pointer-events: none;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.toast-success { background: #16a34a; color: #fff; }
#toast.toast-error   { background: #dc2626; color: #fff; }
#toast.toast-info    { background: #6366f1; color: #fff; }

/* ── Utility classes used on admin pages ─── */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    padding: 20px;
}
.btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    background: #6366f1; color: #fff;
    padding: 8px 16px; border-radius: 7px;
    font-size: 13px; font-weight: 500;
    cursor: pointer; border: none;
    transition: background .15s;
    text-decoration: none;
}
.btn-primary:hover { background: #4f46e5; }
.btn-secondary {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fff; color: #374151;
    padding: 8px 16px; border-radius: 7px;
    font-size: 13px; font-weight: 500;
    cursor: pointer; border: 1px solid #d1d5db;
    transition: background .15s;
    text-decoration: none;
}
.btn-secondary:hover { background: #f9fafb; }
.btn-danger {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fee2e2; color: #b91c1c;
    padding: 8px 16px; border-radius: 7px;
    font-size: 13px; font-weight: 500;
    cursor: pointer; border: 1px solid #fecaca;
    transition: background .15s;
    text-decoration: none;
}
.btn-danger:hover { background: #fecaca; }
.page-header {
    padding: 24px 32px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}
.page-body { padding: 28px 32px; flex: 1; }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 12px; }
.media-thumb {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: #e2e8f0;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color .15s;
}
.media-thumb.selected { border-color: #6366f1; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }


/* Drag & drop upload zone */
.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 32px;
    text-align: center;
    transition: border-color .2s, background .2s;
    cursor: pointer;
}
.upload-zone.dragover { border-color: #6366f1; background: #eef2ff; }
