body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: Arial, sans-serif;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.spinner-overlay.show {
    display: flex;
}

.spinner-container {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top-color: #4ECDC4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
    margin: 0;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.toggle-menu-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 12px 20px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background: rgba(78, 205, 196, 0.9);
    color: white;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.toggle-menu-btn:hover {
    background: rgba(69, 183, 209, 0.9);
    transform: scale(1.05);
}

.toggle-menu-btn:active {
    transform: scale(0.95);
}

.side-menu {
    position: fixed;
    top: 0;
    right: -350px;
    width: 320px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.side-menu.open {
    right: 0;
}

/* Botón de cerrar menú (visible solo en móvil) */
.close-menu-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 107, 107, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: none;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.close-menu-btn:hover {
    background: rgba(255, 60, 60, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.close-menu-btn:active {
    transform: scale(0.95);
}

.side-menu h2 {
    margin: 20px 20px 10px 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4ECDC4;
    flex-shrink: 0;
}

.menu-scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
    margin-bottom: 10px;
}

.side-menu h2 {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #4ECDC4;
    padding-bottom: 10px;
}

.menu-section {
    margin-bottom: 25px;
}

.menu-section label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: bold;
    font-size: 14px;
}

.menu-section select,
.menu-section input[type="color"] {
    width: 100%;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.menu-section select:hover,
.menu-section input[type="color"]:hover {
    border-color: #4ECDC4;
}

.menu-section input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.small-btn {
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    background: #85C1E2;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.small-btn:hover {
    background: #6BA8CC;
}

.apply-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    background: #52B788;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.apply-btn:hover {
    background: #45a078;
    transform: scale(1.02);
}

.apply-btn:active {
    transform: scale(0.98);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #4ECDC4;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #45B7D1;
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #4ECDC4;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #45B7D1;
    transform: scale(1.2);
}

/* Acordeones */
.accordion {
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
}

.accordion-header {
    width: 100%;
    padding: 12px 15px;
    background: #f0f0f0;
    border: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: bold;
    transition: background 0.3s ease;
}

.accordion-header:hover {
    background: #e0e0e0;
}

.accordion-header span:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
}

.accordion-icon {
    transition: transform 0.3s ease;
    font-size: 12px;
}

.accordion.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
}

.accordion.active .accordion-content {
    max-height: 1000px;
    padding: 15px;
}

.hidden {
    display: none !important;
}

/* Checkbox Grid */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: normal;
    margin: 0;
}

.checkbox-grid input[type="checkbox"] {
    cursor: pointer;
}

/* Textarea */
textarea {
    width: 100%;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    resize: vertical;
    transition: border-color 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: #4ECDC4;
}

textarea:hover {
    border-color: #4ECDC4;
}

/* Paleta de colores */
.color-palette {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin: 10px 0;
}

.color-option {
    width: 100%;
    aspect-ratio: 1;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.color-option.selected {
    border-color: #333;
    transform: scale(1.05);
    box-shadow: 0 0 0 2px white, 0 0 0 4px #333;
}

/* Botones de acción */
.action-buttons {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid #ddd;
    flex-shrink: 0;
}

.action-btn {
    flex: 1;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

#regenerate {
    background: #4ECDC4;
}

#regenerate:hover {
    background: #45B7D1;
    transform: scale(1.02);
}

#download {
    background: #F4A261;
}

#download:hover {
    background: #E76F51;
    transform: scale(1.02);
}

.action-btn:active {
    transform: scale(0.98);
}

/* Botones de preset */
.preset-btn {
    width: 100%;
    padding: 8px;
    margin-bottom: 5px;
    font-size: 13px;
    border: 2px solid #ddd;
    border-radius: 5px;
    background: white;
    color: #555;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    border-color: #4ECDC4;
    background: #f0f9f9;
    color: #4ECDC4;
}

.preset-btn:active {
    transform: scale(0.98);
}

/* Input number */
input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

input[type="number"]:hover,
input[type="number"]:focus {
    outline: none;
    border-color: #4ECDC4;
}

/* Pokemon Search Component */
.pokemon-search-wrapper {
    position: relative;
}

.pokemon-search-container {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

#pokemon-search {
    flex: 1;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

#pokemon-search:focus {
    outline: none;
    border-color: #4ECDC4;
}

#add-pokemon-btn {
    padding: 8px 16px;
    white-space: nowrap;
}

/* Custom Suggestions Dropdown */
.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: white;
    border: 2px solid #4ECDC4;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    margin-top: -8px;
}

.suggestions-dropdown.show {
    display: block;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: linear-gradient(90deg, #e0f7fa 0%, #f0f9f9 100%);
}

.suggestion-item.active {
    background: linear-gradient(90deg, #b2ebf2 0%, #e0f7fa 100%);
}

.suggestion-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    object-fit: contain;
    padding: 2px;
    flex-shrink: 0;
}

.suggestion-name {
    text-transform: capitalize;
    font-size: 14px;
    color: #333;
    font-weight: 500;
    flex: 1;
}

.suggestion-id {
    font-size: 11px;
    color: #999;
    font-weight: normal;
}

.suggestions-dropdown::-webkit-scrollbar {
    width: 8px;
}

.suggestions-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.suggestions-dropdown::-webkit-scrollbar-thumb {
    background: #4ECDC4;
    border-radius: 4px;
}

.suggestions-dropdown::-webkit-scrollbar-thumb:hover {
    background: #44A08D;
}

.pokemon-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: #f8f8f8;
    border-radius: 5px;
    min-height: 50px;
    max-height: 200px;
    overflow-y: auto;
}

.pokemon-tag-list:empty::after {
    content: "No hay Pokémon seleccionados";
    color: #999;
    font-style: italic;
    font-size: 13px;
}

.pokemon-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.pokemon-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.pokemon-tag-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    object-fit: contain;
}

.pokemon-tag-name {
    text-transform: capitalize;
}

.pokemon-tag-remove {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: transform 0.2s ease;
}

.pokemon-tag-remove:hover {
    transform: scale(1.3);
}

/* Generation Toggle Buttons */
.gen-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 12px;
}

.gen-action-btn {
    padding: 6px 10px;
    font-size: 11px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.gen-action-btn:hover {
    background: #4ECDC4;
    color: white;
    border-color: #4ECDC4;
}

.gen-toggle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.gen-toggle-btn {
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    color: #999;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.gen-toggle-btn::before {
    content: "Gen ";
    font-size: 10px;
    font-weight: normal;
}

.gen-toggle-btn:hover {
    border-color: #4ECDC4;
    transform: translateY(-2px);
}

.gen-toggle-btn.active {
    background: linear-gradient(135deg, #4ECDC4 0%, #44A08D 100%);
    color: white;
    border-color: #4ECDC4;
    box-shadow: 0 4px 8px rgba(78, 205, 196, 0.3);
}

.gen-toggle-btn:active {
    transform: translateY(0);
}

/* Mejorar renderizado de pixel art en canvas */
canvas {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
}

/* Responsive: Mobile Portrait */
@media screen and (max-width: 768px) {
    .side-menu {
        width: 100%;
        right: -100%;
    }
    
    .side-menu.open {
        right: 0;
        left: 0;
    }
    
    /* Mostrar botón de cerrar solo en móvil */
    .close-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Ajustar el título para dar espacio al botón */
    .side-menu h2 {
        padding-right: 55px; /* 40px button width + 15px spacing */
    }
    
    /* Asegurar que los botones de acción siempre sean visibles */
    .action-buttons {
        position: sticky;
        bottom: 0;
        z-index: 10;
        background: rgba(255, 255, 255, 0.98);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* Ajustar el contenido scrolleable para que no tape los botones */
    .menu-scrollable-content {
        padding-bottom: 10px;
        max-height: calc(100vh - 180px); /* Ajustar según altura de header + botones */
    }
}

@media screen and (max-width: 768px) and (orientation: portrait) {
    /* En portrait, asegurar que el menú use todo el espacio disponible */
    .side-menu {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height para móviles */
    }
    
    /* Reducir padding en móvil para más espacio */
    .menu-scrollable-content {
        padding: 0 15px;
    }
    
    .side-menu h2 {
        margin: 15px 15px 10px 15px;
        font-size: 18px;
    }
    
    /* Hacer los botones más grandes y táctiles en móvil */
    .action-btn {
        padding: 14px;
        font-size: 15px;
        min-height: 48px; /* Tamaño mínimo recomendado para táctil */
    }
}

/* Estilos para selector de tipos */
#types-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.type-toggle-btn {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    padding: 8px 12px;
    border: 2px solid white;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

.type-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.type-toggle-btn.active {
    opacity: 1;
}

.type-toggle-btn:not(.active) {
    opacity: 0.6;
    border-color: transparent;
}