/* Corrección de scroll del Pin Maker y distribución vertical adaptable.
   Se carga después de creator-studio.css para prevalecer sobre sus límites de viewport. */

html:has(body #creator-view:not(.hidden)) {
    height: auto !important;
    min-height: 100%;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior-y: auto;
}

body:has(#creator-view:not(.hidden)) {
    height: auto !important;
    min-height: 100vh;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: auto;
}

main:has(#creator-view:not(.hidden)) {
    height: auto !important;
    min-height: 100vh !important;
    max-height: none !important;
    overflow: visible !important;
}

#creator-view:not(.hidden) {
    height: auto !important;
    min-height: 100vh !important;
    max-height: none !important;
    overflow: visible !important;
}

#creator-view:not(.hidden) .creator-workspace {
    height: auto !important;
    min-height: calc(100vh - 78px);
    max-height: none !important;
    overflow: visible !important;
    /* Separar el lienzo de las propiedades y permitir que la página crezca
       cuando la pantalla sea baja o el inspector tenga muchos controles. */
    grid-template-rows: auto minmax(440px, 62vh) auto !important;
    grid-template-areas:
        "categories assets toolbar layers"
        "categories assets canvas layers"
        "categories assets properties properties" !important;
    align-items: stretch;
}

#creator-view:not(.hidden) .gacha-tabs-bar {
    height: 100%;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: auto !important;
}

#creator-view:not(.hidden) .gacha-options-container {
    height: 100%;
    min-height: 560px;
    max-height: none;
    overflow: hidden;
}

#creator-view:not(.hidden) .gacha-grid {
    min-height: 0;
    max-height: none;
    overflow: auto;
    overscroll-behavior: auto !important;
}

#creator-view:not(.hidden) .canvas-container {
    height: auto !important;
    min-height: 440px;
    max-height: none !important;
    overflow: auto;
    overscroll-behavior: auto !important;
    scrollbar-gutter: stable;
}

#creator-view:not(.hidden) .layers-manager-container {
    height: 100%;
    min-height: 440px;
    max-height: none;
    overflow: hidden;
}

#creator-view:not(.hidden) .layers-list {
    min-height: 100px;
    max-height: min(56vh, 620px);
    overflow: auto;
    overscroll-behavior: auto !important;
}

#creator-view:not(.hidden) .element-properties-box {
    height: auto !important;
    min-height: 220px;
    max-height: none !important;
    overflow: visible !important;
    align-self: start;
}

@media (max-width: 1099px) {
    main:has(#creator-view:not(.hidden)),
    body:has(#creator-view:not(.hidden)),
    #creator-view:not(.hidden),
    #creator-view:not(.hidden) .creator-workspace {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    #creator-view:not(.hidden) .creator-workspace {
        grid-template-rows: auto auto minmax(360px, 62vh) auto auto !important;
        grid-template-areas:
            "categories categories categories categories"
            "assets assets toolbar toolbar"
            "assets assets canvas canvas"
            "layers layers layers layers"
            "properties properties properties properties" !important;
        min-height: 100vh;
    }

    #creator-view:not(.hidden) .gacha-options-container {
        height: auto;
        min-height: 320px;
        max-height: none;
    }

    #creator-view:not(.hidden) .layers-manager-container {
        height: auto;
        min-height: 220px;
    }

    #creator-view:not(.hidden) .element-properties-box {
        height: auto !important;
        min-height: 180px;
    }
}

@media (max-width: 759px) {
    #creator-view:not(.hidden) .creator-workspace {
        grid-template-columns: minmax(0, 1fr) !important;
        grid-template-rows: auto auto auto minmax(300px, 62vh) auto auto !important;
        grid-template-areas:
            "categories"
            "assets"
            "toolbar"
            "canvas"
            "layers"
            "properties" !important;
    }

    #creator-view:not(.hidden) .gacha-options-container {
        min-height: 240px;
        max-height: none;
    }

    #creator-view:not(.hidden) .canvas-container {
        min-height: 300px;
        height: 62vh !important;
        max-height: 650px !important;
    }
}

/* Mantener la barra principal visible y dar más presencia al logo. */
.topbar-logo {
    display: block;
    object-fit: contain;
    width: auto;
    max-width: min(260px, 24vw) !important;
    max-height: 88px !important;
}

/* Los botones ilustrados de Modelos_del_menu deben ser más legibles.
   Este archivo se carga al final, por eso prevalece sobre los tamaños base. */
.menu-art-button > img,
.topbar-actions .menu-art-button > img {
    height: 64px !important;
    max-width: 212px !important;
    object-fit: contain;
}

#creator-view .creator-header-actions .menu-art-button > img,
.rating-view-container .creator-header-actions .menu-art-button > img {
    height: 58px !important;
    max-width: 190px !important;
}

/* Iconos ilustrados de acciones secundarias algo más grandes. */
.btn-img > img {
    height: 78px;
}
.btn-img-large > img {
    height: 78px;
}

/* Scroll chaining: al llegar al borde de una biblioteca, capa o lienzo,
   la rueda puede continuar desplazando la página del Pin Maker. */
#creator-view:not(.hidden) .gacha-tabs-bar,
#creator-view:not(.hidden) .gacha-grid,
#creator-view:not(.hidden) .layers-list,
#creator-view:not(.hidden) .canvas-container {
    overscroll-behavior: auto !important;
    scroll-behavior: auto;
}

@media (max-width: 1250px) {
    .topbar-logo { max-width: min(230px, 23vw) !important; max-height: 80px !important; }
    .menu-art-button > img,
    .topbar-actions .menu-art-button > img { height: 58px !important; max-width: 186px !important; }
    #creator-view .creator-header-actions .menu-art-button > img,
    .rating-view-container .creator-header-actions .menu-art-button > img { height: 54px !important; max-width: 172px !important; }
}

@media (max-width: 850px) {
    .topbar-logo { max-width: min(240px, 58vw) !important; max-height: 76px !important; }
    .menu-art-button > img,
    .topbar-actions .menu-art-button > img { height: 52px !important; max-width: 170px !important; }
    #creator-view .creator-header-actions .menu-art-button > img,
    .rating-view-container .creator-header-actions .menu-art-button > img { height: 48px !important; max-width: 155px !important; }
    .btn-img > img, .btn-img-large > img { height: 68px; }
}

@media (max-width: 560px) {
    .topbar-logo { max-width: min(230px, 76vw) !important; max-height: 68px !important; }
    .menu-art-button > img,
    .topbar-actions .menu-art-button > img { height: 46px !important; max-width: 146px !important; }
    #creator-view .creator-header-actions .menu-art-button > img,
    .rating-view-container .creator-header-actions .menu-art-button > img { height: 42px !important; max-width: 134px !important; }
    .btn-img > img, .btn-img-large > img { height: 58px; }
}


/* FIX 2026-10-27: selector de dimensiones siempre visible y fuera de la barra
   de herramientas, para que no desaparezca cuando la barra se envuelve. */
#creator-view:not(.hidden) .canvas-container {
    position: relative !important;
}
#creator-view .pin-canvas-size-overlay {
    position: absolute;
    z-index: 30;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 16px);
    padding: 7px 9px;
    color: #edf4ff;
    background: rgba(15, 23, 42, .94);
    border: 1px solid #59708c;
    border-radius: 8px;
    box-shadow: 0 5px 18px rgba(0,0,0,.3);
    box-sizing: border-box;
}
#creator-view .pin-canvas-size-overlay-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
    line-height: 1.15;
}
#creator-view .pin-canvas-size-overlay-kicker {
    color: #9db5d2;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
}
#creator-view #pinCanvasSizeDisplay {
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
#creator-view #pinCanvasSizeBtn {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 6px 9px;
    color: #f8fbff;
    background: linear-gradient(180deg, #2d69b4, #1e4d89);
    border: 1px solid #7daee7;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
    cursor: pointer;
}
#creator-view #pinCanvasSizeBtn:hover {
    background: linear-gradient(180deg, #397bc9, #245b9d);
}
.img-wrapper.custom-pointer-dragging {
    opacity: .58 !important;
    pointer-events: none !important;
    filter: drop-shadow(0 3px 8px rgba(0,0,0,.45));
}
body.tier-image-custom-dragging, body.tier-image-custom-dragging * {
    cursor: grabbing !important;
    user-select: none !important;
}
@media (max-width: 760px) {
    #creator-view .pin-canvas-size-overlay {
        top: 5px;
        right: 5px;
        gap: 6px;
        padding: 5px 6px;
        flex-wrap: wrap;
    }
    #creator-view #pinCanvasSizeDisplay { font-size: 10px; }
    #creator-view #pinCanvasSizeBtn { font-size: 10px; min-height: 27px; padding: 4px 6px; }
}
