/* --- ESTILOS GENERALES --- */
body {
    font-family: Arial, sans-serif;
    overflow: hidden;
}

/* Reducción de redundancia: Consolidación de 'image-rendering' y estilos base */
#paint-canvas,
#game-canvas {
    /* width y height se definirán en JS en función del tamaño de grid y la escala de visualización */
    /* Se eliminan los 640px fijos */
    /* Asegura un escalado limpio sin suavizado entre píxeles */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    touch-action: none;
    transition: box-shadow 0.2s;
}

.controls-group {
    border: 1px solid #444;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
}

/* --- ESTILOS DE LA BARRA INFERIOR --- */
#bottom-bar-wrapper {
    height: 140px;
}

#tiles-bar-container {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 1rem;
    padding: 10px 15px;
    flex-grow: 1;
}

#tiles-bar {
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
    padding-bottom: 10px;
}

/* --- ESTILOS DE LOS TILES --- */

.tile-selector-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 5px;
    min-width: 70px;

    /* Habilitar Drag and Drop */
    cursor: grab;
}

/* Estilo para el elemento que se está arrastrando */
.dragging {
    opacity: 0.5;
}

/* Estilo para el área de donde se puede soltar el elemento */
.drag-over {
    border-bottom: 3px solid yellow !important;
}

.tile-selector {
    width: 70px;
    height: 70px;
    min-width: 70px;
    min-height: 70px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #212529;
    border: 2px solid transparent;
    margin-top: 10px;
}

.tile-selector.selected {
    background-color: #343a40;
    outline: 2px solid #00bcd4;
    outline-offset: -2px;
    border: 2px solid transparent;
}

.tile-selector.hidden {
    opacity: 0.4 !important;
}

.add-tile-button {
    background-color: #198754;
    color: white;
    border: 2px dashed #343a40;
    font-size: 24px;
    line-height: 60px;
    text-align: center;
    cursor: pointer;
}

/* El botón de añadir no se arrastra */
.add-tile-button-wrapper {
    cursor: default;
}

.tile-preview-canvas {
    width: 32px;
    height: 32px;
    border: 1px solid #666;
    image-rendering: pixelated;
}

/* ID Label: Izquierda */
.tile-id-label {
    position: absolute;
    top: -2px;
    left: 0;
    background-color: #000;
    color: white;
    padding: 0 5px;
    border: 1px solid #333;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 10;
}

/* Visibilidad Toggle: Derecha */
.visibility-toggle {
    position: absolute;
    top: -2px;
    right: 0;
    cursor: pointer;
    z-index: 15;
    font-size: 0.8rem;
    color: #00bcd4;
    padding: 0 3px;
}

.visibility-toggle.hidden-icon {
    color: #dc3545;
}

/* Paleta de Colores Estilos */
#color-palette-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-top: 10px;
}

.color-swatch {
    width: 100%;
    padding-bottom: 100%;
    border: 1px solid #555;
    cursor: pointer;
    transition: border-color 0.1s;
}

.color-swatch:hover {
    border: 2px solid white;
}

/* Estilo para los botones de la barra lateral (Ahora todos son btn-light por defecto) */
.btn-light {
    background-color: white !important;
    border-color: #f8f9fa !important;
}

/* --- ESTILOS PARA EL MODAL DE EXPORTACIÓN PNG --- */
.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

#export-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.export-tile-wrapper {
    text-align: center;
    border: 1px solid #444;
    padding: 10px;
    border-radius: 5px;
}

.export-preview-canvas {
    border: 1px solid #00bcd4;
    image-rendering: pixelated;
    background-color: #333;
    /* Para ver la transparencia */
}

/* Corrección/Consolidación para herramienta ACTIVA */
.tool-icon-container.active {
    background-color: #007bff;
    /* Fondo azul visible */
    border-color: #007bff;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.7);
    /* Opcional: añade un brillo */
}

/* Estilo para el ICONO (<i>) dentro del contenedor activo (incluye .tool-button.active i) */
.tool-icon-container.active i,
.tool-button.active i {
    color: #ffffff !important;
    /* El icono se pone blanco */
}

/* CSS MÍNIMO: Solo para la disposición flex de la aplicación y ajustes de tamaño */
.app-container {
    min-height: 99.8vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex-grow: 1;
    display: flex;
    overflow: hidden;
}

.tools-sidebar {
    width: 60px;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    overflow-y: auto;
}

.center-area {
    flex-grow: 1;
    min-width: 0;
    overflow: hidden;
}

.bottom-bar {
    flex-shrink: 0;
    height: 180px;
    overflow-x: auto;
}

.tool-icon-container {
    width: 40px;
    height: 40px;
    margin: 0 auto 0.75rem;
    background-color: white;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #6c757d;
    cursor: pointer;
}

.panel-title {
    color: #ffc107;
    font-size: 0.8rem !important;
    margin-bottom: 0.5rem !important;
    font-weight: normal !important;
}

.active-tool {
    color: #ffc107 !important;
    /* Mantenemos este color para otros elementos, pero el selector de arriba es más específico para el botón */
}

.inactive-tool {
    color: #adb5bd !important;
}

/* Estilo para las celdas normales de la paleta */
.palette-cell {
    transition: border 0.1s, box-shadow 0.1s;
    position: relative;
}

/* Indicador de paleta activa: sin borde, solo sombra/glow */
.preset-palette-cell.active {
    /* Sombra interior blanca y sombra exterior azul para indicar selección */
    box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px #007bff;
    z-index: 10;
    /* Asegurar que la sombra se vea sobre el fondo */
}


/* CSS CRÍTICO (Ajusta los estilos de tu aplicación) */
.fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(40, 40, 40, 0.95);
    /* Fondo oscuro semitransparente */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

#modal-content {
    background: #f8f8f8;
    color: #333;
    padding: 30px;
    width: 90%;
    max-width: 900px;
    height: 80%;
    max-height: 700px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
}

#project-list-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#project-list {
    flex-grow: 1;
    overflow-y: scroll;
    border: 1px solid #ccc;
    padding: 0;
    /* Quitar padding para control total del li */
    list-style: none;
    margin: 0;
    background-color: #ffffff;
}

/* ESTILOS CLAVE PARA LA VISUALIZACIÓN DE LA LISTA */
#project-list li {
    cursor: pointer;
    padding: 10px 15px;
    /* Aumentar padding para más espacio */

    /* HACER LA LÍNEA DE SEPARACIÓN MÁS OSCURA Y VISIBLE */
    border-bottom: 1px solid #c0c0c0;
    /* Línea gris oscuro/plata */

    display: flex;
    justify-content: space-between;
    /* Alinear Nombre a la izquierda y Fecha a la derecha */
    align-items: center;
    transition: background-color 0.1s;
}

/* Eliminar la línea de la última fila */
#project-list li:last-child {
    border-bottom: none;
}

#project-list li:hover {
    background: #e0e0e0;
    /* Hover más pronunciado */
}

/* Estilo para el texto de la fecha */
#project-list li span {
    font-size: 0.85em;
    color: #666;
    font-weight: normal;
}

/* Estilo para el nombre (negrita ya provista por el JS con <strong>) */
#project-list li strong {
    color: #000;
}

.hidden {
    display: none !important;
}

/* Nuevo CSS para resaltar el elemento seleccionado */
#project-list li.active-project {
    background-color: #b0e0ff !important;
    /* Azul claro para el resaltado */
    border-left: 5px solid #007bff;
    /* Barra azul fuerte a la izquierda */
    padding-left: 10px;
    /* Ajuste por el borde izquierdo */
}

/* ---------------------------------------------------- */
/* Contenedor principal de la lista (Muestra las paletas en flujo horizontal) */
/* ---------------------------------------------------- */
.palette-list-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 15px;
    padding: 10px;
}

/* ---------------------------------------------------- */
/* Contenedor de cada paleta listada (el botón clicleable) */
/* ---------------------------------------------------- */
.palette-select-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 250px;
    padding: 8px;
    background-color: #2c2c2c;
    border: 2px solid #444;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.palette-select-item:hover {
    border-color: #007bff;
    background-color: #383838;
}

/* ---------------------------------------------------- */
/* Diseño de la Cuadrícula de Previsualización (5x11) */
/* ---------------------------------------------------- */
.palette-preview-grid {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    grid-template-rows: repeat(5, 1fr);
    width: 100%;
    height: auto;
    aspect-ratio: 11 / 5;
    gap: 1px;
    background-color: #000;
    border: 1px solid #1a1a1a;
    padding: 2px;
}

.preview-cell {
    width: 100%;
    height: 100%;
}

/* ---------------------------------------------------- */
/* Nombre de la paleta (pequeño y sin negrita) */
/* ---------------------------------------------------- */
.palette-name-label-small {
    color: #ccc;
    font-size: 0.9em;
    font-weight: normal;
    margin-top: 5px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}