/* Variables CSS para temas */
:root {
    --bg-body: #1a1a1a;
    --bg-panel: #222;
    --bg-card: #1e1e1e;
    --bg-input: #2a2a2a;
    --bg-btn: #2a2a2a;
    --bg-btn-hover: #3a3a3a;
    --bg-tab: #2a2a2a;
    --bg-tab-active: #ffd966;
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --text-muted: #777;
    --border-color: #333;
    --border-light: #444;
    --shadow-color: rgba(0,0,0,0.6);
    --heart-color: #ff6b6b;
    --accent-color: #ffd966;
}

body.light-mode {
    --bg-body: #f0f0f0;
    --bg-panel: #ffffff;
    --bg-card: #f7f7f7;
    --bg-input: #e8e8e8;
    --bg-btn: #e0e0e0;
    --bg-btn-hover: #d0d0d0;
    --bg-tab: #e0e0e0;
    --bg-tab-active: #e74c3c;
    --text-primary: #222;
    --text-secondary: #555;
    --text-muted: #888;
    --border-color: #ccc;
    --border-light: #ddd;
    --shadow-color: rgba(0,0,0,0.15);
    --accent-color: #e74c3c;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 20px;
    user-select: none;
    transition: background 0.3s, color 0.3s;
}

#app {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    color: var(--accent-color);
    flex-shrink: 0;
}

header h1 {
    font-size: 26px;
    font-weight: 300;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

header .sub {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 0;
}

.theme-btn {
    margin-left: auto;
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 0 6px;
    color: var(--text-primary);
    transition: transform 0.2s;
}
.theme-btn:hover {
    transform: scale(1.1);
}

.main-layout {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.avatar-panel {
    flex: 0 0 200px;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-panel);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 8px;
    box-shadow: 0 4px 12px var(--shadow-color);
    gap: 6px;
    position: sticky;
    top: 16px;
    align-self: flex-start;
    max-height: 480px;
    transition: background 0.3s, box-shadow 0.3s;
}

.avatar-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
}

.avatar-container img {
    width: 128px;
    height: auto;
    image-rendering: pixelated;
}

.heart-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: transparent;
    border: none;
    color: var(--heart-color);
    cursor: pointer;
    padding: 2px;
    transition: 0.2s;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.8));
}

.heart-btn:hover {
    transform: scale(1.1);
}

.direction-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dir-btn {
    background: var(--bg-btn);
    border: none;
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.dir-btn:hover {
    background: var(--bg-btn-hover);
    color: var(--text-primary);
}

.avatar-actions {
    display: flex;
    gap: 4px;
    width: 100%;
    justify-content: center;
}

.action-btn {
    background: var(--bg-btn);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    transition: 0.2s;
    white-space: nowrap;
}

.action-btn:hover {
    background: var(--bg-btn-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

#fav-count {
    font-weight: bold;
    color: var(--accent-color);
    min-width: 14px;
    text-align: center;
    font-size: 10px;
}

.search-container {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0 2px;
}

#id-search {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    color: var(--text-primary);
    padding: 2px 5px;
    font-size: 10px;
    outline: none;
    text-align: center;
    font-family: monospace;
    min-width: 0;
}

#id-search:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 6px rgba(255, 217, 102, 0.2);
}

#id-search::placeholder {
    color: var(--text-muted);
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: 0.2s;
}

.clear-btn:hover {
    color: var(--text-primary);
}

.content-panel {
    flex: 1;
    min-width: 280px;
    background: var(--bg-card);
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 4px 12px var(--shadow-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background 0.3s, box-shadow 0.3s;
}

.tabs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.sub-tabs {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
    margin-top: -2px;
}

.tab-btn {
    background: var(--bg-tab);
    border: none;
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 11px;
    transition: 0.2s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.tab-btn svg {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tab-btn:hover:not(:disabled) {
    background: var(--bg-btn-hover);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--bg-tab-active);
    color: #fff;
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.3);
}

.tab-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sub-tabs .tab-btn {
    font-size: 10px;
    padding: 3px 10px;
    background: var(--bg-btn);
    border-radius: 12px;
}

.sub-tabs .tab-btn.active {
    background: var(--bg-tab-active);
    color: #fff;
}

.gender-panel {
    display: none;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.gender-panel .gender-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.gender-btn {
    background: var(--bg-btn);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 4px 14px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    transition: 0.2s;
}

.gender-btn:hover {
    background: var(--bg-btn-hover);
    color: var(--text-primary);
}

.gender-btn.active {
    background: var(--bg-tab-active);
    color: #fff;
    border-color: var(--bg-tab-active);
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.3);
}

#sections-wrapper {
    flex: 1;
    min-height: 180px;
    overflow: hidden;
}

.grid-section {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
    padding: 2px 0;
    max-height: 340px;
    overflow-y: auto;
    align-content: start;
}

.grid-section.active {
    display: grid;
}

.grid-section::-webkit-scrollbar {
    width: 5px;
}

.grid-section::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 3px;
}

.grid-section::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.thumbnail {
    width: 72px;
    height: 72px;
    background: var(--bg-input);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    image-rendering: pixelated;
    padding: 4px;
    position: relative;
    flex-shrink: 0;
}

/* --- CAMBIO AQUÍ: object-fit: cover y tamaño fijo --- */
.thumbnail img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    display: block;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.thumbnail:hover {
    border-color: var(--border-color);
}

.thumbnail.active {
    border-color: var(--bg-tab-active);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

.thumbnail.none {
    background: #3a2a2a;
    border-color: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: var(--heart-color);
    user-select: none;
}

.thumbnail.none:hover {
    border-color: var(--heart-color);
    background: #4a2a2a;
}

.thumbnail.none.active {
    border-color: var(--bg-tab-active);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

.thumbnail.hidden {
    display: none;
}

.palette-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 6px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

.palette-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
}

.palette-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-right: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: 0.15s;
    flex-shrink: 0;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: var(--bg-tab-active);
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.5);
}

.color-swatch.x-swatch {
    background: #3a2a2a;
    color: var(--heart-color);
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: var(--border-color);
    cursor: pointer;
    line-height: 1;
}

.color-swatch.x-swatch.active {
    border-color: var(--bg-tab-active);
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.5);
    background: #4a2a2a;
}

.color-swatch.x-swatch:hover {
    border-color: var(--heart-color);
    background: #4a2a2a;
}

.no-colors-msg {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.import-container {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    border-top: 1px solid var(--border-color);
    padding-top: 6px;
    margin-top: 2px;
}

#import-url {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    color: var(--text-primary);
    padding: 3px 6px;
    font-size: 10px;
    outline: none;
    font-family: monospace;
    min-width: 0;
}

#import-url:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.2);
}

#import-url::placeholder {
    color: var(--text-muted);
}

.import-btn {
    background: var(--bg-btn);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    border-radius: 5px;
    padding: 3px 6px;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
    line-height: 1;
}

.import-btn:hover {
    background: var(--bg-btn-hover);
    border-color: var(--accent-color);
    color: var(--text-primary);
}

.url-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border-radius: 6px;
    padding: 3px 6px;
    border: 1px solid var(--border-color);
}

#avatar-url {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 6px 2px;
    font-size: 12px;
    font-family: monospace;
    outline: none;
    min-width: 0;
}

#copy-url {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: 0.2s;
    display: flex;
    align-items: center;
}

#copy-url:hover {
    background: var(--bg-btn);
    color: var(--text-primary);
}

footer {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    justify-content: center;
    align-items: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 14px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px var(--shadow-color);
    border: 1px solid var(--border-color);
    transition: background 0.3s;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    transition: 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.favorites-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.fav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--bg-panel);
    border-radius: 6px;
    padding: 6px 4px;
    border: 1px solid var(--border-color);
    transition: 0.2s;
}

.fav-item:hover {
    border-color: var(--accent-color);
}

.fav-thumb {
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
    border-radius: 4px;
    background: var(--bg-body);
    flex-shrink: 0;
    object-fit: cover;
    object-position: center 50%;
}

.fav-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    overflow: hidden;
}

.fav-info .fav-label {
    font-size: 9px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}

.fav-actions {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
}

.fav-actions button {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    border-radius: 3px;
    padding: 2px 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    font-size: 12px;
}

.fav-actions button:hover {
    background: var(--bg-btn-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.fav-actions .fav-delete:hover {
    border-color: var(--heart-color);
    color: var(--heart-color);
}

.modal-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.clear-favs {
    background: #3a2a2a;
    border: 1px solid var(--border-color);
    color: var(--heart-color);
    padding: 4px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 11px;
    transition: 0.2s;
}

.clear-favs:hover {
    background: #4a2a2a;
    border-color: var(--heart-color);
}

.zoom-content {
    max-width: 580px;
    max-height: 90vh;
}

.zoom-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    gap: 12px;
}

.zoom-avatar-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.zoom-avatar-container img {
    width: 192px;
    height: auto;
    image-rendering: pixelated;
}

.zoom-controls {
    display: flex;
    gap: 16px;
}

.zoom-controls .dir-btn {
    width: 36px;
    height: 36px;
}

@media (max-width: 700px) {
    .main-layout {
        flex-direction: column;
    }

    .avatar-panel {
        flex: unset;
        max-width: 180px;
        margin: 0 auto;
        position: static;
        max-height: 400px;
    }

    .grid-section {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        max-height: 260px;
    }

    .thumbnail {
        width: 60px;
        height: 60px;
        padding: 2px;
    }

    .thumbnail img {
        width: 56px;
        height: 56px;
    }

    .modal-content {
        width: 95%;
    }

    .favorites-list {
        grid-template-columns: 1fr;
    }

    .zoom-avatar-container img {
        width: 160px;
        height: auto;
    }
}