/* ====
   WRAPPER PRINCIPAL
   ==== */
.tibia-enc-wrapper {
    width: 100%;
    padding: 10px 0;
}

/* ====
   TOPBAR
   ==== */
.tibia-enc-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.tibia-enc-filter-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    background: rgba(49,67,226,0.8);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.tibia-enc-filter-toggle:hover {
    background: #3143e2;
}

.tibia-enc-counter {
    font-size: 12px;
    color: #888;
    margin-left: auto;
}

/* ====
   LAYOUT PRINCIPAL (grid + panel)
   ==== */
.tibia-enc-content {
    display: flex;
    flex-direction: row-reverse;
    gap: 16px;
    align-items: flex-start;
    position: relative;
}

.tibia-enc-grid-area {
    flex: 1;
    min-width: 0;
    transition: all 0.3s ease;
}

/* ====
   PANEL LATERAL
   ==== */
.tibia-enc-filter-panel {
    width: 240px;
    min-width: 240px;
    overflow: hidden;
    background: #fff;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    padding: 14px;
    position: relative;
    z-index: 100;
    transform: translateX(calc(100% + 16px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    margin-left: -256px;
}

.tibia-enc-filter-panel.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    margin-left: 0;
}

/* Panel en modo overlay */
.tibia-enc-filter-panel.overlay-mode {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    width: 0;
    border-radius: 0;
    z-index: 9999;
}

.tibia-enc-filter-panel.overlay-mode.open {
    width: 280px;
    min-width: 280px;
}

/* ====
   OVERLAY OSCURO
   ==== */
.tibia-enc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9998;
    animation: encFadeOverlay 0.3s ease;
}

.tibia-enc-overlay.active {
    display: block;
}

@keyframes encFadeOverlay {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ====
   CABECERA DEL PANEL
   ==== */
.tibia-enc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 8px;
}

.tibia-enc-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    color: #555;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.tibia-enc-panel-close:hover {
    border-color: #3143e2;
    color: #3143e2;
    background: rgba(49, 67, 226, 0.05);
}

.tibia-enc-panel-reset {
    padding: 5px 10px;
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 11px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tibia-enc-panel-reset:hover {
    border-color: #e74c3c;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.05);
}

/* ====
   SECCIONES DEL PANEL
   ==== */
.tibia-enc-panel-section {
    margin-bottom: 4px;
}

.tibia-enc-panel-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    margin-bottom: 8px;
}

.tibia-enc-panel-separator {
    height: 1px;
    background: #f0f0f0;
    margin: 12px 0;
}

/* Input nombre */
.tibia-enc-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 13px;
    transition: border-color 0.2s ease;
    background: #fff;
    color: #333;
    box-sizing: border-box;
}

.tibia-enc-input:focus {
    outline: none;
    border-color: #3143e2;
    box-shadow: 0 0 0 2px rgba(49, 67, 226, 0.15);
}

/* ====
   GRUPOS DE BOTONES
   ==== */
.tibia-enc-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Lista de tipos (columna) */
.tibia-enc-type-list {
    flex-direction: column;
    gap: 4px;
}

.tibia-enc-filter-btn {
    padding: 5px 4px;
    border: none;
    border-radius: 5px;
    background: rgba(49, 67, 226, 0.4);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    line-height: 1.4;
}

.tibia-enc-filter-btn:hover {
    background: rgba(49,67,226,0.8);
    color: #fff;
}

.tibia-enc-filter-btn.active {
    background: #3143e2;
    color: #fff;
}

/* Botones dificultad con color */
.difficulty-btn-harmless.active    { background: #27ae60; border-color: #27ae60; }
.difficulty-btn-trivial.active     { background: #2ecc71; border-color: #2ecc71; }
.difficulty-btn-easy.active        { background: #f39c12; border-color: #f39c12; }
.difficulty-btn-medium.active      { background: #e67e22; border-color: #e67e22; }
.difficulty-btn-hard.active        { background: #e74c3c; border-color: #e74c3c; }
.difficulty-btn-challenging.active { background: #c0392b; border-color: #c0392b; }
.difficulty-btn-deadly.active      { background: #8e44ad; border-color: #8e44ad; }

/* Botones cantidad */
.tibia-enc-limit-btn {
    min-width: 48px;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
}

/* ====
   LOADING OVERLAY
   ==== */
.tibia-enc-grid-wrapper {
    position: relative;
    min-height: 200px;
}

.tibia-enc-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px;
    gap: 12px;
}

.tibia-enc-loading.hidden {
    display: none;
}

.tibia-enc-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(49, 67, 226, 0.3);
    border-top-color: #3143e2;
    border-radius: 50%;
    animation: encSpin 0.8s linear infinite;
}

.tibia-enc-loading span {
    font-size: 13px;
    color: #555;
}

@keyframes encSpin {
    to { transform: rotate(360deg); }
}

/* ====
   GRID 5 COLUMNAS
   ==== */
.tibia-enc-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    width: 100%;
}

/* ====
   CARD
   ==== */
.tibia-enc-card {
    background: #f2f2f2;
    border-radius: 5px;
    border: 1px solid #dddddd;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease, border-color 0.2s ease;
    animation: encFadeIn 0.3s ease-in-out;
}

.tibia-enc-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(49, 67, 226, 0.15);
    border-color: #3143e2;
    background: rgba(49,67,226,0.1);
}

.tibia-enc-card-inner {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100%;
    justify-content: space-between;
}

/* Imagen */
.tibia-enc-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 0;
}

.tibia-enc-image {
    width: 64px;
    height: 64px;
    object-fit: contain;
    image-rendering: pixelated;
    margin-bottom: 0 !important;
}

/* Nombre y tipo */
.tibia-enc-info {
    text-align: center;
}

.tibia-enc-name {
    font-size: 14px;
    font-weight: bold;
    color: #2c3e50;
    margin: 0 0 2px 0;
    line-height: 1.3;
    letter-spacing: 0.3px;
    word-break: break-word;
}

.tibia-enc-type {
    font-size: 11px;
    color: #888;
    margin: 0;
}

/* Stats */
.tibia-enc-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 4px 0;
    border-top: 1px solid #dddddd;
    border-bottom: 1px solid #dddddd;
}

.tibia-enc-stats .stat-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.tibia-enc-stats .stat-icon {
    width: 12px;
    height: 12px;
    object-fit: contain;
    image-rendering: pixelated;
    margin-bottom: 0 !important;
}

.tibia-enc-stats .stat-value {
    font-size: 11px;
    color: #3143e2;
    font-weight: bold;
}

.tibia-enc-stats .stat-separator {
    font-size: 11px;
    color: #ccc;
}

/* Dificultad */
.tibia-enc-difficulty {
    font-size: 11px;
    text-align: center;
}

.difficulty-label {
    font-weight: bold;
    color: #555;
}

.difficulty-harmless    { color: #27ae60; }
.difficulty-trivial     { color: #2ecc71; }
.difficulty-easy        { color: #f39c12; }
.difficulty-medium      { color: #e67e22; }
.difficulty-hard        { color: #e74c3c; }
.difficulty-challenging { color: #c0392b; }
.difficulty-deadly      { color: #8e44ad; }

/* ====
   ELEMENTOS EN CARD
   ==== */
.tibia-enc-elements-box {
    margin-top: 2px;
}

.tibia-enc-elements-box .elements-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.tibia-enc-elements-box .element-column {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 3px 0;
}

.tibia-enc-elements-box .element-title {
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    padding: 2px 4px;
    border-radius: 3px;
    text-align: center;
}

.tibia-enc-elements-box .strong-title {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
    border-bottom: 1px solid #ff6b6b;
}

.tibia-enc-elements-box .neutral-title {
    background: rgba(150, 150, 150, 0.2);
    color: #808080;
    border-bottom: 1px solid #808080;
}

.tibia-enc-elements-box .weak-title {
    background: rgba(0, 204, 0, 0.2);
    color: #00cc00;
    border-bottom: 1px solid #00cc00;
}

.tibia-enc-elements-box .element-icons {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    min-height: 44px;
}

.tibia-enc-elements-box .element-icon {
    width: 12px;
    height: 12px;
    object-fit: contain;
    image-rendering: pixelated;
    cursor: pointer;
    transition: transform 0.2s ease;
    margin-bottom: 0 !important;
}

.tibia-enc-elements-box .element-icon:hover {
    transform: scale(1.3);
}

.tibia-enc-elements-box .element-wrapper {
    position: relative;
    display: inline-block;
    cursor: pointer;
    padding: 5px;
    margin: -5px;
}

.no-element {
    font-size: 10px;
    color: #bbb;
}

/* ====
   TOOLTIP
   ==== */
.tibia-tooltip {
    position: absolute;
    display: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tibia-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: inherit;
}

/* ====
   BOTÓN GUÍA
   ==== */
.tibia-enc-guide-wrapper {
    margin-top: auto;
    padding-top: 4px;
}

.tibia-enc-guide-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 8px;
    background: #dddddd;
    color: #333;
    text-decoration: none;
    border-radius: 5px;
    border-left: 3px solid #3143e2;
    font-size: 10px;
    transition: all 0.3s ease;
    width: 100%;
}

.tibia-enc-guide-button:hover {
    color: #3143e2;
    text-decoration: none;
}

.tibia-enc-guide-button svg {
    flex-shrink: 0;
}

/* ====
   PAGINACIÓN
   ==== */
.tibia-enc-pagination-wrapper {
    margin-top: 24px;
    display: flex;
    justify-content: center;
}

.tibia-enc-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.tibia-enc-page-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tibia-enc-page-btn:hover:not(:disabled):not(.active) {
    border-color: #3143e2;
    color: #3143e2;
    background: rgba(49, 67, 226, 0.05);
}

.tibia-enc-page-btn.active {
    background: #3143e2;
    border-color: #3143e2;
    color: #fff;
    font-weight: bold;
    cursor: default;
}

.tibia-enc-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tibia-enc-page-dots {
    font-size: 13px;
    color: #aaa;
    padding: 0 4px;
    user-select: none;
}

/* ====
   SIN RESULTADOS / ERROR
   ==== */
.tibia-enc-no-results {
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 14px;
}

.tibia-enc-error {
    padding: 20px;
    background: rgba(139, 0, 0, 0.1);
    border: 1px solid #8b0000;
    border-radius: 8px;
    color: #c0392b;
    text-align: center;
    font-size: 14px;
}

/* ====
   ANIMACIONES
   ==== */
@keyframes encFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====
   NOTIFICACIONES TOAST
   ==== */
.bestiary-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999999;
    pointer-events: none;
}

.bestiary-toast {
    background: #34495e;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 500px;
    pointer-events: auto;
    animation: bestiarySlideInRight 0.3s ease-out;
    font-size: 14px;
    line-height: 1.4;
}

.bestiary-toast.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.bestiary-toast.error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.bestiary-toast.warning {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #34495e;
}

.bestiary-toast.info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
}

.bestiary-toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.bestiary-toast-message {
    flex: 1;
}

.bestiary-toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.bestiary-toast-close:hover {
    opacity: 1;
}

@keyframes bestiarySlideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes bestiarySlideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.bestiary-toast.hiding {
    animation: bestiarySlideOutRight 0.3s ease-out forwards;
}

/* ====
   SECCIÓN DE PROGRESO EN CARD
   ==== */
.tibia-enc-progress-section {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid #dddddd;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
}

.tibia-enc-completed-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    background: #27ae60;
    color: #fff;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.5);
    z-index: 1;
    border: 2px solid #fff;
}

.tibia-enc-soul-core-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 36px;
    height: 36px;
    background: rgba(49,67,226,0.4);
    color: #fff;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(41, 128, 185, 0.5);
    z-index: 1;
    border: 2px solid #fff;
}

.tibia-enc-soul-core-badge img {
    width: 15px;
    height: 15px;
    object-fit: contain;
    margin-bottom: 0px !important;
}

.tibia-enc-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tibia-enc-fase-label {
    font-size: 11px;
    font-weight: 700;
    color: #2c3e50;
}

.tibia-enc-kills-label {
    font-size: 11px;
    color: #888;
}

.tibia-enc-progress-bar-wrapper {
    width: 100%;
    height: 6px;
    background: #d2d2d7;
    border-radius: 3px;
    overflow: hidden;
}

.tibia-enc-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3143e2b3, #3143e2);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.tibia-enc-kills-title {
    font-size: 11px;
    font-weight: 700;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.tibia-enc-kills-input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    text-align: center;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.tibia-enc-kills-input:focus {
    outline: none;
    border-color: #3143e2;
    box-shadow: 0 0 0 2px rgba(49, 67, 226, 0.15);
}

.tibia-enc-kills-input:disabled {
    background: #f5f5f5;
    color: #aaa;
    cursor: not-allowed;
}

.tibia-enc-verify-msg {
    font-size: 10px;
    color: #aaa;
    text-align: center;
    line-height: 1.4;
    font-style: italic;
}

/* Botones de fase */
.tibia-enc-fase-btns {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.tibia-enc-fase-btn {
    flex: 1;
    padding: 5px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background: rgba(49,67,226,0.4);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    text-align: center;
}

.tibia-enc-fase-btn:hover {
    background: rgba(49,67,226,0.8);
    color: #fff;
}

.tibia-enc-fase-btn.active {
    background: #3143e2;
    color: #fff;
}

/* Soul Core checkbox row */
.tibia-enc-soul-core-row {
    margin-top: 8px;
}

.tibia-enc-soul-core-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.tibia-enc-soul-core-check {
    display: none;
}

.tibia-enc-soul-core-toggle {
    position: relative;
    width: 42px;
    height: 20px;
    background: #555;
    border-radius: 12px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.tibia-enc-soul-core-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 5px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.tibia-enc-soul-core-check:checked + .tibia-enc-soul-core-toggle {
    background: #3143e2;
}

.tibia-enc-soul-core-check:checked + .tibia-enc-soul-core-toggle::after {
    transform: translateX(18px);
}

/* ====
   RESPONSIVE
   ==== */

/* Tablet (768px - 1200px) → 3 columnas */
@media (max-width: 1200px) {
    .tibia-enc-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Móvil grande (480px - 768px) → 2 columnas */
@media (max-width: 768px) {
    .tibia-enc-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tibia-enc-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .tibia-enc-input,
    .tibia-enc-select {
        width: 100%;
    }

    .tibia-enc-counter {
        margin-left: 0;
        text-align: center;
    }

    .bestiary-toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .bestiary-toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* Móvil pequeño (< 480px) → 1 columna */
@media (max-width: 480px) {
    .tibia-enc-grid {
        grid-template-columns: 1fr;
    }

    .tibia-enc-page-btn {
        min-width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .tibia-enc-progress-section {
        gap: 4px;
    }

    .tibia-enc-kills-input {
        font-size: 12px;
        padding: 3px 6px;
    }
}