/* ====
   WRAPPER PRINCIPAL
   ==== */
.tibia-items-wrapper {
    width: 100%;
    padding: 10px 0;
}

/* ====
   TOPBAR
   ==== */
.tibia-items-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.tibia-items-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-items-filter-toggle:hover {
    background: #3143e2;
}

.tibia-items-counter {
    font-size: 12px;
    color: #888;
    margin-left: auto;
}

/* ====
   LAYOUT PRINCIPAL (grid + panel)
   ==== */
.tibia-items-content {
    display: flex;
    flex-direction: row-reverse;
    gap: 16px;
    align-items: flex-start;
    position: relative;
}

.tibia-items-grid-area {
    flex: 1;
    min-width: 0;
    transition: all 0.3s ease;
}

/* ====
   PANEL LATERAL
   ==== */
.tibia-items-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-items-filter-panel.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    margin-left: 0;
}

/* Panel en modo overlay */
.tibia-items-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-items-filter-panel.overlay-mode.open {
    width: 280px;
    min-width: 280px;
}

/* ====
   OVERLAY OSCURO
   ==== */
.tibia-items-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9998;
    animation: itemsFadeOverlay 0.3s ease;
}

.tibia-items-overlay.active {
    display: block;
}

@keyframes itemsFadeOverlay {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ====
   CABECERA DEL PANEL
   ==== */
.tibia-items-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 8px;
}

.tibia-items-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-items-panel-close:hover {
    border-color: #3143e2;
    color: #3143e2;
    background: rgba(49,67,226,0.05);
}

.tibia-items-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-items-panel-reset:hover {
    border-color: #e74c3c;
    color: #e74c3c;
    background: rgba(231,76,60,0.05);
}

/* ====
   SECCIONES DEL PANEL
   ==== */
.tibia-items-panel-section {
    margin-bottom: 4px;
}

.tibia-items-panel-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    margin-bottom: 8px;
}

.tibia-items-panel-separator {
    height: 1px;
    background: #f0f0f0;
    margin: 12px 0;
}

/* Input nombre */
.tibia-items-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-items-input:focus {
    outline: none;
    border-color: #3143e2;
    box-shadow: 0 0 0 2px rgba(49,67,226,0.15);
}

/* Select categoría */
.tibia-items-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

/* ====
   GRUPOS DE BOTONES
   ==== */
.tibia-items-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tibia-items-filter-btn {
    padding: 5px 8px;
    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-items-filter-btn:hover {
    background: rgba(49,67,226,0.8);
    color: #fff;
}

.tibia-items-filter-btn.active {
    background: #3143e2;
    color: #fff;
}

/* Botones cantidad */
.tibia-items-limit-btn {
    min-width: 48px;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
}

@keyframes itemsSpin {
    to { transform: rotate(360deg); }
}

/* ====
   GRID — 6 columnas base
   ==== */
.tibia-items-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    width: 100%;
}

/* ====
   CARD
   ==== */
.tibia-item-card {
    background: #f2f2f2;
    border-radius: 5px;
    border: 1px solid #ddd;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease, border-color 0.2s ease;
    animation: itemsFadeIn 0.3s ease-in-out;
}

.tibia-item-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.05);
}

.tibia-item-card-inner {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100%;
}

/* Imagen */
.tibia-item-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 0;
}

.tibia-item-image {
    width: 64px;
    height: 64px;
    object-fit: contain;
    image-rendering: pixelated;
    margin-bottom: 0 !important;
}

/* Nombre */
.tibia-item-name {
    font-size: 13px;
    font-weight: bold;
    color: #2c3e50;
    text-align: center;
    margin: 0;
    line-height: 1.3;
    word-break: break-word;
    min-height: calc(13px * 1.3 * 2);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Categoría */
.tibia-item-category {
    font-size: 11px;
    color: #888;
    text-align: center;
    margin: 0;
}

/* Stats (precio + delivery) */
.tibia-item-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 0 2px;
    border-top: 1px solid #ddd;
    margin-top: auto;
}

.tibia-item-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.tibia-item-stat-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #aaa;
    letter-spacing: 0.3px;
}

.tibia-item-stat-value {
    font-size: 11px;
    font-weight: 700;
    color: #34495e;
}

/* Badge delivery */
.tibia-item-delivery {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
}

.tibia-item-delivery.si {
    background: rgba(39,174,96,0.15);
    color: #27ae60;
}

.tibia-item-delivery.no {
    background: rgba(231,76,60,0.12);
    color: #e74c3c;
}

/* ====
   IMBUEMENT BADGE
   ==== */
.tibia-item-imbuement-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 36px;
    height: 36px;
    z-index: 2;
}

.tibia-item-imbuement-badge img {
    width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0px 2px 6px 0px #666;
    margin-bottom: 0 !important;
    object-fit: contain;
    display: block;
}

/* ====
   OUTFIT BADGE
   ==== */
.tibia-item-outfit-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 36px;
    height: 36px;
    border-radius: 5px;
    box-shadow: 0px 2px 6px 0px #666;
    z-index: 2;
    overflow: hidden;
}

.tibia-item-outfit-badge img.tibia-outfit-img {
    width: 36px;
    height: 36px;
    margin-bottom: 0 !important;
    object-fit: contain;
    display: block;
}

/* ====
   PAGINACIÓN
   ==== */
.tibia-items-pagination-wrapper {
    margin-top: 24px;
    display: flex;
    justify-content: center;
}

.tibia-items-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.tibia-items-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-items-page-btn:hover:not(:disabled):not(.active) {
    border-color: #3143e2;
    color: #3143e2;
    background: rgba(49,67,226,0.05);
}

.tibia-items-page-btn.active {
    background: #3143e2;
    border-color: #3143e2;
    color: #fff;
    font-weight: bold;
    cursor: default;
}

.tibia-items-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tibia-items-page-dots {
    font-size: 13px;
    color: #aaa;
    padding: 0 4px;
    user-select: none;
}

/* ====
   SIN RESULTADOS / ERROR
   ==== */
.tibia-items-no-results {
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 14px;
}

.tibia-items-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 itemsFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====
   TOAST NOTIFICATIONS
   ==== */
.tibia-items-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
}

.tibia-items-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: itemsSlideInRight 0.3s ease-out;
    font-size: 14px;
    line-height: 1.4;
}

.tibia-items-toast.success { background: linear-gradient(135deg, #28a745 0%, #20c997 100%); }
.tibia-items-toast.error   { background: linear-gradient(135deg, #dc3545 0%, #c82333 100%); }
.tibia-items-toast.warning { background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%); color: #34495e; }
.tibia-items-toast.info    { background: linear-gradient(135deg, #17a2b8 0%, #138496 100%); }

.tibia-items-toast-icon    { font-size: 24px; flex-shrink: 0; }
.tibia-items-toast-message { flex: 1; }

.tibia-items-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;
}

.tibia-items-toast-close:hover { opacity: 1; }

@keyframes itemsSlideInRight {
    from { transform: translateX(400px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}

@keyframes itemsSlideOutRight {
    from { transform: translateX(0);     opacity: 1; }
    to   { transform: translateX(400px); opacity: 0; }
}

.tibia-items-toast.hiding {
    animation: itemsSlideOutRight 0.3s ease-out forwards;
}

/* ====
   RESPONSIVE
   ==== */

/* 5 columnas */
@media (max-width: 1400px) {
    .tibia-items-grid { grid-template-columns: repeat(5, 1fr); }
}

/* 4 columnas */
@media (max-width: 1100px) {
    .tibia-items-grid { grid-template-columns: repeat(4, 1fr); }
}

/* 3 columnas */
@media (max-width: 860px) {
    .tibia-items-grid { grid-template-columns: repeat(3, 1fr); }
}

/* 2 columnas */
@media (max-width: 600px) {
    .tibia-items-grid { grid-template-columns: repeat(2, 1fr); }

    .tibia-items-counter { margin-left: 0; text-align: center; }

    .tibia-items-toast-container { top: 10px; right: 10px; left: 10px; }
    .tibia-items-toast { min-width: auto; max-width: 100%; }
}

/* 1 columna */
@media (max-width: 380px) {
    .tibia-items-grid { grid-template-columns: 1fr; }

    .tibia-items-page-btn {
        min-width: 28px;
        height: 28px;
        font-size: 11px;
    }
}