/* style_table.css */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --chrome-size: 32px;
    --cell-width: 250px;
    --cell-height: 150px;
    --surface-dark: #151515;
    --text-primary: rgba(255,255,255,0.92);
    --text-secondary: rgba(255,255,255,0.72);
    --text-muted: rgba(255,255,255,0.62);
    --focus-ring: #2d8fff;
    --modal-surface: #222;
    --modal-surface-alt: #1a1a1a;
    --modal-border: rgba(255,255,255,0.1);
    --modal-shadow: 0 25px 60px rgba(0,0,0,0.45);
}

#container {
    z-index: 1;
}


body {
    margin: 0;
    padding: 0;
    overflow: hidden; /* No barras de scroll en el navegador */
    font-family: 'Inter', sans-serif;
    background-color: #000; /* Fondo negro */
    display: flex;
    justify-content: center; /* Centra horizontalmente */
    align-items: center; /* Centra verticalmente */
    position: relative;
    height: 100dvh; /* Toda la ventana */
    width: 100vw; /* Todo el ancho */
    min-width: 0;
    touch-action: none;
}

.border-container {
    position: fixed;  /* Modificado aquí */
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: black;
    z-index: 2;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.blockworld-name {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
}

.blockworld-name-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    text-align: center;
    padding: 2px 8px;
    outline: none;
    min-width: 100px;
    max-width: 300px;
    transition: border-color 0.2s ease;
}

.blockworld-name-input:hover {
    border-color: rgba(255,255,255,0.2);
}

.blockworld-name-input:focus {
    border-color: #0059b3;
    background: rgba(255,255,255,0.05);
}

.blockset-counter {
    color: var(--text-muted);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    margin-left: 12px;
}

.zoom-indicator {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
}

.blockset-search {
    position: absolute;
    top: 50%;
    right: 98px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    width: clamp(190px, 28vw, 350px);
    padding: 2px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(20,20,20,0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-sizing: border-box;
}

.blockset-search-bottom {
    position: absolute;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    height: 80%;
    width: clamp(180px, 24vw, 300px);
    margin-right: 0;
    z-index: 3;
    padding: 0 10px;
}

.blockset-search-icon {
    color: var(--text-muted);
    font-size: 10px;
}

.blockset-search-input {
    flex: 1;
    min-width: 70px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
}

.blockset-search-input::placeholder {
    color: rgba(255,255,255,0.45);
}

.blockset-search-input.no-results {
    color: #ffb6b6;
}

.search-result-count {
    min-width: 34px;
    text-align: center;
    color: var(--text-muted);
    font-size: 10px;
    font-family: 'Inter', sans-serif;
}

.search-nav-btn {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.82);
    cursor: pointer;
    padding: 0;
    font-size: 9px;
}

.search-nav-btn:hover {
    border-color: #0059b3;
    color: #fff;
    background: rgba(0,89,179,0.5);
}

.search-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.search-clear-btn {
    background: rgba(179, 0, 0, 0.2);
}

.search-clear-btn:hover {
    background: rgba(179, 0, 0, 0.55);
    border-color: rgba(255, 87, 87, 0.9);
}



.border-container.top,
.border-container.bottom {
    height: var(--chrome-size);
    width: 100%;
    left: 0;
}

.border-container.left,
.border-container.right {
    width: var(--chrome-size);
    height: calc(100% - (var(--chrome-size) * 2));  /* Aquí restamos los espacios de los bordes superior e inferior */
}

.border-container.top {
    top: 0;
}

.border-container.right {
    right: 0;
    top: var(--chrome-size);  /* Aquí añadimos el espacio del borde superior */
}

.border-container.bottom {
    bottom: 0;
}

.border-container.left {
    left: 0;
    top: var(--chrome-size);  /* Aquí añadimos el espacio del borde superior */
}

.triangle-button {
    width: 0;
    height: 0;
    background-color: transparent;
    border-style: solid;
    cursor: pointer;
    z-index: 10;
}

.triangle-button:hover {
    opacity: 0.8;
}

.top .triangle-button {
    border-width: 0 15px 15px 15px;
    border-color: transparent transparent #0059b3 transparent;
}

.right .triangle-button {
    border-width: 15px 0 15px 15px;
    border-color: transparent transparent transparent #0059b3;
}

.bottom .triangle-button {
    border-width: 15px 15px 0 15px;
    border-color: #0059b3 transparent transparent transparent;
}

.left .triangle-button {
    border-width: 15px 15px 15px 0;
    border-color: transparent #0059b3 transparent transparent;
}

.content-container {
    position: absolute;
    top: 25px;
    right: 25px;
    bottom: 25px;
    left: 25px;
    padding: 10px;
    background-color: #f5f5f5;
    overflow-y: auto;
    box-sizing: border-box;
    word-wrap: break-word;
    outline: none;
    font-size: 16px;
}

.logo-link {
    display: flex;
    align-items: center;
    margin-right: 16px;
    flex-shrink: 0;
}

.logo {
    height: 20px;
    width: auto;
}

/* Dimension display (read-only) */
.dim-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 10px;
    font-family: 'Inter', sans-serif;
    color: var(--text-secondary);
    user-select: none;
}

.dim-display .dim-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dim-display .dim-axis {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dim-display .dim-val {
    font-weight: 500;
    color: var(--text-muted);
}

/* ── GRID FRAME & EXPAND BUTTONS ─────────────────────── */

.grid-frame {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: max-content;
    height: max-content;
}

.grid-row-area {
    display: flex;
    align-items: stretch;
}

/* Shared expand button base */
.grid-expand-btn {
    background: transparent;
    border: 1px dashed rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.78);
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.65;
    transition: opacity 0.2s ease, border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
    user-select: none;
}

@media (hover: hover) and (pointer: fine) {
    .grid-expand-btn {
        opacity: 0;
    }

    /* Show on hover of the frame */
    .grid-frame:hover .grid-expand-btn {
        opacity: 1;
    }
}

.grid-expand-btn:hover {
    border-color: #0059b3;
    color: #0059b3;
    background-color: rgba(0, 89, 179, 0.06);
}

/* Right-side button: adds column */
.grid-expand-col {
    width: 32px;
    align-self: stretch;
    margin-left: 10px;
}

/* Bottom button: adds row */
.grid-expand-row {
    height: 32px;
    width: 100%;
    margin-top: 10px;
}

.inner-container {
    display: flex;
    align-items: center;
    position: absolute;
    width: 94%;
    height: 94%;
    justify-content: flex-start;  /* Asegúrate de que esté configurado en flex-start */
    padding: 20px;
}

.bottom .inner-container {
    justify-content: flex-end;
    height: 100%;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Coordinate display in bottom-left */
.coord-display {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
}


.blockset.selected {
    outline: 2px solid #0059b3;
}



#center-text-btn {
    margin-right: 10px;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background-color: #ccc;
    cursor: se-resize;
}



   .blockworld-btn {
    background-color: #0059b3;
    color: #fff;
    border: none;

    /* Bordes redondeados en el lado derecho */
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    border-left: 1px solid #333; /* Agregamos el borde izquierdo */
    padding: 0 8px; /* Mantener el mismo padding que .copy-btn */
    cursor: pointer;
    margin-left: 0; /* Sin margen entre .copy-btn y .blockworld-btn */
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: start;
    height: 80%; /* Se adapta a la altura del contenedor padre */
    box-sizing: border-box; /* Para incluir el padding en la altura total */
}

.blockworld-btn:hover {
    background-color: #555;
}

.base-btn-style {
    background-color: #333;
    color: rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 0 10px;
    cursor: pointer;
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    height: 80%;
    box-sizing: border-box;
    margin-right: 6px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.base-btn-style:last-child {
    margin-right: 0; /* Eliminar el margen del último botón para que no tenga un espacio extra en el extremo derecho */
}

.base-btn-style:hover {
    background-color: #0059b3;
    color: #fff;
    border-color: #0059b3;
}

.base-btn-style:focus-visible,
.grid-expand-btn:focus-visible,
.blockworld-name-input:focus-visible,
.modal-btn:focus-visible,
.blockset-search-input:focus-visible,
.search-nav-btn:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Save button with unsaved changes */
.base-btn-style.has-changes {
    background-color: #0059b3;
    color: #fff;
    border-color: #0059b3;
    animation: pulse-save 2s ease-in-out infinite;
}

@keyframes pulse-save {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Estilo de borde izquierdo */
.border-left {
    border-left: 1px solid #333;
}

/* Bordes redondeados */
.rounded-right {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.rounded-left {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

#delete-button i {
    margin: 0 5px; /* Este valor puede ser ajustado según tu preferencia */
}

#delete-button:hover {
    background-color: rgb(146, 62, 62);
}



html, body {
    height: 100%;
}


.grid-container {
    width: 100%; /* Ocupa todo el ancho disponible */
    height: 100%; /* Ocupa toda la ventana */
    position: absolute; /* Para permitir el movimiento */
    transform-origin: top left; /* Escala desde la esquina superior izquierda */
    overflow: visible; /* Evita barras de scroll */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: none;
}



.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* Ajusta el número de columnas */
    gap: 10px; /* Espaciado entre celdas */
    transform: scale(1); /* Escala inicial */
    width: max-content; /* Tamaño dinámico según contenido */
    height: max-content; /* Tamaño dinámico según contenido */
}

.cell {
    border: 1px solid rgba(255,255,255,0.08);
    height: var(--cell-height);
    border-radius: 10px; /* Esquinas redondeadas */
    background-color: var(--surface-dark);
    transition: border-color 0.2s ease;
}

/* Highlight valid (empty) cells during drag */
.cell.drag-over {
    border-color: rgba(0,89,179,0.5);
    background-color: rgba(0,89,179,0.05);
}

.selected {
    /* Algún estilo para indicar selección, por ejemplo, un borde o color de fondo */
    border: 2px solid #0059b3;
}

.blockset {
    border: 1px solid rgba(255,255,255,0.08);
    height: var(--cell-height);
    border-radius: 10px; /* Esquinas redondeadas */
    background-color: #0072e6;
    align-items: center; /* Centrar verticalmente */
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transform-origin: center center;
    display: flex;
    justify-content: center;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.blockset-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.92);
    font-size: 8px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    padding: 3px 8px 3px 6px;
    border-radius: 20px;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.blockset-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: #2ecc71;
    flex-shrink: 0;
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.85);
    animation: badge-pulse 2.5s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 5px rgba(46, 204, 113, 0.85); }
    50%       { opacity: 0.65; box-shadow: 0 0 2px rgba(46, 204, 113, 0.4); }
}

.blockset:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0,114,230,0.3);
}

.blockset.search-match {
    border-color: rgba(255, 209, 102, 0.92);
    box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.65), 0 2px 8px rgba(0,0,0,0.4);
}

.blockset.search-current {
    border-color: rgba(255, 136, 0, 0.95);
    box-shadow: 0 0 0 3px rgba(255, 136, 0, 0.9), 0 0 22px rgba(255, 136, 0, 0.45), 0 2px 8px rgba(0,0,0,0.4);
}

/* Dragging state */
.blockset.dragging {
    opacity: 0.7;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    z-index: 1000;
    pointer-events: none;
    position: fixed !important;
}

.blockset-content {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Para prevenir el desbordamiento de contenido */
}

.cell, .blockset {
    width: var(--cell-width);
    height: var(--cell-height);
    /* ... otros estilos ... */
}

.highlight-blockset {
    border: 2px solid rgb(75, 3, 54); /* Borde rojo */
    border-radius: 10px; /* Bordes redondeados */
    background-color: rgba(190, 15, 173, 0.846); /* Fondo semitransparente */
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5); /* Sombra para resaltar */
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out; /* Animación suave */
}

.highlight-blockset:hover {
    transform: scale(1.1); /* Aumenta ligeramente al pasar el cursor */
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8); /* Más sombra al hacer hover */
}

/* Modal System (Reusable)
   Future modals: use app-modal-overlay + app-modal-card + app-modal-title +
   app-modal-input + app-modal-actions + app-modal-btn(+variant). */
.app-modal-overlay,
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-modal-card,
.modal-box {
    background: linear-gradient(145deg, var(--modal-surface) 0%, var(--modal-surface-alt) 100%);
    border: 1px solid var(--modal-border);
    border-radius: 12px;
    padding: 22px 24px;
    width: min(420px, calc(100vw - 28px));
    min-width: 280px;
    text-align: left;
    font-family: 'Inter', sans-serif;
    box-shadow: var(--modal-shadow);
}

.app-modal-title,
.modal-text {
    color: white;
    font-size: 15px;
    margin: 0 0 16px 0;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.app-modal-actions,
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 2px;
}

.app-modal-input,
.modal-input {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 16px 0;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid #444;
    background: #333;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    outline: none;
}

.app-modal-input:focus,
.modal-input:focus {
    border-color: #0059b3;
    background: rgba(0, 89, 179, 0.14);
}

.context-menu {
    position: fixed;
    z-index: 3200;
    min-width: 150px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(18,18,18,0.96);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    padding: 6px;
}

.context-menu-item {
    width: 100%;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.9);
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.context-menu-item:hover {
    background: rgba(0,89,179,0.38);
    color: #fff;
}

.app-modal-btn,
.modal-btn {
    padding: 6px 18px;
    border-radius: 8px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.app-modal-btn-secondary,
.modal-btn-cancel {
    background: #333;
    color: rgba(255,255,255,0.8);
}

.app-modal-btn-secondary:hover,
.modal-btn-cancel:hover {
    background: #444;
}

.app-modal-btn-danger,
.modal-btn-delete {
    background: #b30000;
    color: white;
}

.app-modal-btn-danger:hover,
.modal-btn-delete:hover {
    background: #cc0000;
}

.modal-btn-primary,
.app-modal-btn-primary {
    background: #0059b3;
    color: #fff;
}

.modal-btn-primary:hover,
.app-modal-btn-primary:hover {
    background: #006edb;
}

/* Undo button */
#undoDelete {
    background-color: #444;
    transition: background-color 0.2s ease, opacity 0.3s ease;
}

#undoDelete:hover {
    background-color: #0059b3;
}

@media (max-width: 1200px) {
    :root {
        --chrome-size: 26px;
        --cell-width: 190px;
        --cell-height: 120px;
    }

    .blockworld-name {
        max-width: 52vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .blockworld-name-input {
        max-width: 42vw;
    }

    .blockset-search {
        width: clamp(170px, 30vw, 280px);
    }

    .search-result-count {
        min-width: 28px;
        font-size: 9px;
    }
}

@media (max-width: 768px) {
    :root {
        --chrome-size: 22px;
        --cell-width: 150px;
        --cell-height: 96px;
    }

    .logo {
        height: 16px;
    }

    .zoom-indicator,
    .coord-display,
    .blockset-counter {
        font-size: 10px;
    }

    .base-btn-style {
        font-size: 10px;
        padding: 0 8px;
        margin-right: 4px;
    }

    .blockworld-name-input {
        min-width: 72px;
        max-width: 34vw;
        font-size: 12px;
    }

    .blockset-search {
        right: 84px;
        width: clamp(130px, 36vw, 190px);
        height: 20px;
        gap: 4px;
        padding: 2px 8px;
    }

    .blockset-search-bottom {
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        width: clamp(110px, 34vw, 180px);
        height: 80%;
        margin-right: 0;
        padding: 0 8px;
    }

    .blockset-search-input {
        font-size: 10px;
    }

    .search-result-count {
        display: none;
    }

    .search-nav-btn {
        width: 16px;
        height: 16px;
        font-size: 8px;
    }
}
