/* L2 HTM Builder - Custom Styles */

/* Menus laterais rolam de forma independente; no editor, a roda do mouse
   continua a rolagem natural da pagina quando o canvas chega ao limite. */
aside {
    overscroll-behavior-y: contain;
}

/* Banner slots: contidos, no fluxo normal.
   contain: layout/paint faz o slot virar o "containing block" dos elementos
   internos — ads que o script injeta com position:fixed ficam presos ao slot
   (e cortados por overflow:hidden), em vez de flutuarem sobre a pagina. */
#bannerSlot1,
#bannerSlot2 {
    position: relative;
    contain: layout paint;
    flex: none;
    overflow: hidden;
    max-height: 72px;
}

/* Defesa reforcada: NENHUM elemento dentro dos slots de banner pode ser fixed/sticky.
   Ads injetados por scripts de terceiros (ex: data527.click) tentam usar position:fixed
   para sobrepor o conteudo — isso deve ser bloqueado dentro dos slots. */
#bannerSlot1 [style*="fixed"],
#bannerSlot1 [style*="sticky"],
#bannerSlot1 ins,
#bannerSlot1 iframe,
#bannerSlot2 [style*="fixed"],
#bannerSlot2 [style*="sticky"],
#bannerSlot2 ins,
#bannerSlot2 iframe {
    position: static !important;
    z-index: auto !important;
}

/* Defesa MAXIMA: nenhum ad pode usar position:fixed no body.
   Scripts de terceiros (data527.click, etc) injetam ins/div/iframe com
   position:fixed direto no body — isso sobrepoe todo o layout.
   Exclui apenas banners internos do app (update e instalacao PWA). */
body > div[style*="fixed"]:not(#appUpdateBanner):not(#pwaInstallBanner):not(#pwaToastMsg),
body > div[style*="sticky"]:not(#appUpdateBanner):not(#pwaInstallBanner):not(#pwaToastMsg),
body > iframe[style*="fixed"],
body > ins[style*="fixed"],
body > ins,
body > iframe {
    position: static !important;
    z-index: auto !important;
    display: none !important;
}

/* Esconde e bloqueia qualquer elemento injetado no <body> que nao seja do proprio app.
   Ad providers (data527.click, etc) injetam divs vazios diretamente no <body>,
   depois do #bannerSlot2, que ficam no fluxo do documento e criam espaco vazio.
   display:none + position:static garante que ficam invisiveis e sem espaco,
   mesmo que o JS (containFloatingAd) falhe ou o elemento nao tenha position:fixed. */
body > *:not(header):not(main):not(aside):not(nav):not(#bannerSlot1):not(#bannerSlot2):not(#editor-wrapper):not(#save-modal):not(#toast):not(#appUpdateBanner):not(#pwaInstallBanner):not(#pwaToastMsg):not(#canvas-container):not(script):not(style):not(link):not(meta):not(noscript) {
    position: static !important;
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #4a4a6a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a5a8a;
}

/* CodeMirror Overrides */
.CodeMirror {
    height: 100% !important;
    min-height: 300px;
    font-size: 13px;
    background: #1a1a2e !important;
    color: #e0e0e0 !important;
}

.CodeMirror-gutters {
    background: #16213e !important;
    border-right: 1px solid #4a4a6a !important;
}

.CodeMirror-linenumber {
    color: #a0a0a0 !important;
}

/* Canvas Elements - Free Positioning */
.canvas-element {
    position: absolute;
    cursor: move;
    transition: outline 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    z-index: 1;
}

.canvas-element:hover {
    outline: 2px dashed rgba(212, 175, 55, 0.5);
}

.canvas-element.selected {
    outline: 2px solid #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

/* Em smallbuttons o rÃ³tulo fica fora da face; selecione somente a Ã¡rea clicÃ¡vel. */
.canvas-element.has-external-label:hover,
.canvas-element.has-external-label.selected {
    outline: none;
    box-shadow: none;
}

.canvas-element.has-external-label:hover .l2-btn-face {
    outline: 2px dashed rgba(212, 175, 55, 0.5);
}

.canvas-element.has-external-label.selected .l2-btn-face {
    outline: 2px solid #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.canvas-element.dragging {
    opacity: 0.8;
    z-index: 1000 !important;
}

/* Element badges */
.element-badge {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 18px;
    height: 18px;
    background: #d4af37;
    color: #1a1a2e;
    font-size: 10px;
    font-weight: bold;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 10;
}

.canvas-element:hover .element-badge,
.canvas-element.selected .element-badge {
    opacity: 1;
}

/* Drop Zone */
#canvas-dropzone {
    position: relative;
    min-height: 400px;
    transition: background-color 0.2s ease;
    overflow: visible;
    padding-bottom: 40px;
}

#canvas-dropzone.drag-over {
    background-color: rgba(212, 175, 55, 0.05);
    outline: 2px dashed rgba(212, 175, 55, 0.3);
}

/* Visible area marker - where scroll starts */
.scroll-marker.visible {
    position: absolute;
    left: 0;
    right: 0;
    top: 400px; /* set by JS per version */
    height: 0;
    border-top: 2px dashed rgba(255, 80, 80, 0.55);
    z-index: 2;
    pointer-events: none;
}

.scroll-marker.visible::before {
    content: '\25BC';
    position: absolute;
    top: -9px;
    right: -4px;
    color: #ff5050;
    font-size: 12px;
}

.scroll-marker.visible span {
    position: absolute;
    top: -12px;
    left: 8px;
    font-size: 9px;
    color: #ff5050;
    background: rgba(26, 26, 46, 0.95);
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
}

/* Scroll area label */
.scroll-area {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 40px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 80, 80, 0.03),
        rgba(255, 80, 80, 0.03) 8px,
        transparent 8px,
        transparent 16px
    );
    border-top: 1px dashed rgba(255, 80, 80, 0.35);
    pointer-events: none;
}

.scroll-label {
    font-size: 9px;
    color: #ff8080;
    background: rgba(26, 26, 46, 0.9);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}

/* Resize Handle */
.resize-handle {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    background: #d4af37;
    border-radius: 2px;
    cursor: se-resize;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.canvas-element.selected .resize-handle {
    opacity: 1;
}

/* L2 Button Styles in Canvas */
.l2-btn-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #e0e0e0;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    background: linear-gradient(180deg, #5a5a8a 0%, #4a4a6a 50%, #3a3a5a 100%);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

/* Override background for different button types */
.l2-btn-preview[data-bgl2="big1"] {
    background: linear-gradient(180deg, #4a6a5a 0%, #3a5a4a 50%, #2a4a3a 100%);
}

.l2-btn-preview[data-bgl2="nav"] {
    background: linear-gradient(180deg, #6a5a5a 0%, #5a4a4a 50%, #4a3a3a 100%);
}

.l2-btn-preview[data-bgl2="small"],
.l2-btn-preview[data-bgl2="smallover"] {
    background: linear-gradient(180deg, #4a4a6a 0%, #3a3a5a 50%, #2a2a4a 100%);
}

.l2-btn-preview[data-bgl2="small"]:hover,
.l2-btn-preview[data-bgl2="smallover"]:hover {
    background: linear-gradient(180deg, #6a6a8a 0%, #5a5a7a 50%, #4a4a6a 100%);
}

.l2-btn-tex {
    position: absolute;
    top: 1px;
    left: 0;
    right: 0;
    font-size: 8px;
    line-height: 1;
    color: #d4af37;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    pointer-events: none;
    z-index: 1;
}

/* Smart guides (guias de alinhamento estilo Photoshop) */
.smart-guides {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1000;
}
.smart-guide-v,
.smart-guide-h {
    position: absolute;
    background: #ff2d95;
    box-shadow: 0 0 3px rgba(255, 45, 149, 0.85);
}
.smart-guide-v {
    top: 0;
    bottom: 0;
    width: 1px;
}
.smart-guide-h {
    left: 0;
    right: 0;
    height: 1px;
}

.l2-btn-preview:hover {
    background: linear-gradient(180deg, #6a6a9a 0%, #5a5a8a 50%, #4a4a7a 100%);
}

/* Texto de botão pequeno (fora do botão, padrão L2) */
.l2-btn-text-outside {
    text-align: center;
    font-size: 9px;
    margin-top: 1px;
    color: #e0e0e0;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.l2-btn-square {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #e0e0e0;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    background: linear-gradient(180deg, #5a5a8a 0%, #4a4a6a 50%, #3a3a5a 100%);
    cursor: pointer;
}

.l2-separator {
    height: 1px;
    background: linear-gradient(90deg, transparent, #808080, transparent);
}

.l2-separator-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 4px;
    border: 1px dashed rgba(212, 175, 55, 0.28);
    border-radius: 3px;
    color: #d4af37;
    background: rgba(26, 26, 46, 0.3);
    font-size: 9px;
    line-height: 1.15;
    text-align: center;
    word-break: break-word;
    min-height: 18px;
}

.l2-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 4px;
    border: 1px solid rgba(212, 175, 55, 0.28);
    border-radius: 3px;
    color: #d4af37;
    background: rgba(26, 26, 46, 0.45);
    font-size: 9px;
    line-height: 1.15;
    text-align: center;
    word-break: break-word;
    min-width: 30px;
    min-height: 30px;
}

.l2-spacer {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(212, 175, 55, 0.1) 4px,
        rgba(212, 175, 55, 0.1) 8px
    );
}

.l2-text {
    font-size: 12px;
    line-height: 1.4;
}

.l2-logo {
    height: 56px;
    background: linear-gradient(180deg, #2a2a4e 0%, #1a1a2e 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d4af37;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* Mode Toggle */
.mode-toggle.active {
    background: #d4af37 !important;
    color: #1a1a2e !important;
    font-weight: 600;
}

/* Template Buttons */
.template-btn.active {
    background: #d4af37 !important;
    color: #1a1a2e !important;
}

/* Saved Files */
.saved-file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.saved-file-item:hover {
    background: #4a4a6a;
}

.saved-file-item .file-icon {
    width: 12px;
    height: 12px;
    color: #d4af37;
}

.saved-file-item .file-name {
    flex: 1;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-file-item .file-delete {
    opacity: 0;
    transition: opacity 0.15s ease;
    color: #ff6b6b;
}

.saved-file-item:hover .file-delete {
    opacity: 1;
}

/* Toast Animation */
#toast.show {
    transform: translateY(0) !important;
    opacity: 1 !important;
}

/* Properties Form */
#props-form input[type="text"],
#props-form input[type="number"],
#props-form select {
    font-size: 12px;
}

#props-form label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Alignment Buttons */
.align-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.align-btn:hover {
    background: #5a5a8a !important;
}

.align-btn:active {
    transform: scale(0.95);
}

/* Select tool toggle */
.tool-active {
    border: 1px solid #d4af37 !important;
    color: #d4af37 !important;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
    font-weight: 600;
}

/* Marquee selection box */
.canvas-marquee {
    position: absolute;
    border: 1px dashed rgba(212, 175, 55, 0.9);
    background: rgba(212, 175, 55, 0.08);
    pointer-events: none;
    z-index: 9999;
}

/* Position Inputs */
#prop-x, #prop-y {
    font-family: monospace;
}

/* Responsive */
@media (max-width: 1200px) {
    .w-64 {
        width: 200px;
    }
    .w-72 {
        width: 240px;
    }
}

/* Banner Slots — neutraliza o preflight do Tailwind (img { height: auto }),
   que anulava o atributo height= do HTML e fazia o banner renderizar
   com a altura original da imagem (OTDQmRF.png e 468x100) em vez de 60px. */
#bannerSlot1 img,
#bannerSlot2 img {
    width: 468px !important;
    height: 60px !important;
    object-fit: stretch;
    display: block;
}

@media (max-width: 520px) {
    #bannerSlot1 img,
    #bannerSlot2 img {
        width: 100% !important;
        height: auto !important;
    }
}
