/* ===== TORMENTA 20 ITEM FINDER - ESTILO TORMENTA ===== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Text:ital@0;1&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Cores Tormenta 20 */
    --primary-bg: #1a1410;
    --secondary-bg: #2d2620;
    --tertiary-bg: #3d3530;
    --text-primary: #e8dcc8;
    --text-secondary: #c9bfb0;
    --text-muted: #9a9080;
    --border-color: #4a4238;
    --accent-color: #8b4513;
    --accent-hover: #a0522d;
    --accent-light: #cd853f;
    --danger-color: #d32f2f;
    --success-color: #558b2f;
    --gold-color: #daa520;

    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

body {
    font-family: 'Crimson Text', serif;
    background-color: var(--primary-bg);
    background-image:
        repeating-linear-gradient(90deg,
            transparent,
            transparent 2px,
            rgba(139, 69, 19, 0.03) 2px,
            rgba(139, 69, 19, 0.03) 4px);
    color: var(--text-primary);
    line-height: 1.7;
}

/* ===== LAYOUT ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.container-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-xl);
}

@media (min-width: 1024px) {
    .container-grid {
        grid-template-columns: 3fr 1fr;
    }
}

.content-column {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, #2d2620 0%, #1a1410 100%);
    border-bottom: 3px solid var(--gold-color);
    border-top: 2px solid var(--accent-light);
    padding: var(--spacing-xl) 0;
    margin-bottom: var(--spacing-xl);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(90deg,
            var(--gold-color),
            var(--gold-color) 10px,
            transparent 10px,
            transparent 20px);
}

.header-title {
    font-family: 'Cinzel', serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--gold-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 2px;
}

.header-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.5rem;
}

/* ===== FILTROS ===== */
.filters-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    background-color: var(--secondary-bg);
    padding: var(--spacing-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: var(--spacing-md);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-md) 2.5rem;
    background-color: var(--tertiary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--gold-color);
    box-shadow: 0 0 8px rgba(218, 165, 32, 0.3);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* ===== FILTROS BOTÕES ===== */
.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.filter-btn {
    padding: 0.6rem 1.2rem;
    background-color: var(--tertiary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background-color: var(--accent-color);
    transition: left 0.3s ease;
    z-index: -1;
}

.filter-btn:hover {
    border-color: var(--gold-color);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(218, 165, 32, 0.2);
}

.filter-btn:hover::before {
    left: 0;
}

.filter-btn.active {
    background-color: var(--accent-color);
    border-color: var(--gold-color);
    color: var(--text-primary);
    box-shadow: 0 0 12px rgba(218, 165, 32, 0.4);
}

/* ===== VIEW TOGGLE ===== */
.view-toggle {
    display: flex;
    gap: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    padding-top: var(--spacing-lg);
}

.view-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background-color: var(--tertiary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: 'Crimson Text', serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-btn:hover {
    border-color: var(--gold-color);
    color: var(--text-primary);
}

.view-btn.active {
    background-color: var(--accent-color);
    border-color: var(--gold-color);
    color: var(--text-primary);
}

/* ===== GRID DE ITENS ===== */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    background-color: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    min-height: 300px;
}

.item-card {
    background: linear-gradient(135deg, var(--tertiary-bg) 0%, var(--secondary-bg) 100%);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.item-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold-color), var(--accent-light), var(--gold-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.item-card:hover {
    border-color: var(--gold-color);
    box-shadow: 0 0 16px rgba(218, 165, 32, 0.3), inset 0 0 8px rgba(218, 165, 32, 0.1);
    transform: translateY(-4px);
}

.item-card:hover::before {
    opacity: 1;
}

.item-name {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gold-color);
    margin-bottom: 0.5rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.item-price {
    font-size: 0.9rem;
    color: var(--accent-light);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    background-color: var(--accent-color);
    border: 1px solid var(--accent-light);
    border-radius: 3px;
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
}

.badge-cat {
    background-color: var(--accent-color);
}

.badge-tipo {
    background-color: var(--tertiary-bg);
    border-color: var(--gold-color);
}

.badge-vestido {
    background-color: var(--success-color);
    border-color: #7cb342;
}

.item-spaces {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
    font-size: 1.1rem;
    font-style: italic;
}

/* ===== TABELA ===== */
.table-view-container {
    display: block !important;
    padding: var(--spacing-lg);
}

.table-category-title {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: var(--gold-color);
    margin: var(--spacing-lg) 0 var(--spacing-md) 0;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: var(--spacing-md);
}

.item-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-xl);
    background-color: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.item-table thead {
    background-color: var(--tertiary-bg);
    border-bottom: 2px solid var(--gold-color);
}

.item-table th {
    padding: var(--spacing-md);
    text-align: left;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--gold-color);
    font-size: 0.95rem;
}

.item-table td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.item-table tbody tr {
    transition: all 0.2s ease;
    cursor: pointer;
}

.item-table tbody tr:hover {
    background-color: var(--tertiary-bg);
    box-shadow: inset 0 0 8px rgba(218, 165, 32, 0.1);
}

/* ===== INVENTÁRIO ===== */
.inventory-container {
    background-color: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-lg);
}

.inventory-title {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: var(--gold-color);
    margin-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--gold-color);
    padding-bottom: var(--spacing-md);
}

.inventory-list {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: var(--spacing-lg);
}

.inventory-empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: var(--spacing-lg);
}

.inventory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background-color: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    transition: all 0.2s ease;
}

.inventory-item:hover {
    border-color: var(--gold-color);
    box-shadow: inset 0 0 8px rgba(218, 165, 32, 0.1);
}

.item-info {
    flex: 1;
}

.item-name {
    color: var(--gold-color);
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.item-details {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.item-actions {
    margin-left: var(--spacing-md);
}

.remove-item-btn {
    padding: 0.3rem 0.6rem;
    background-color: var(--danger-color);
    border: none;
    border-radius: 3px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.remove-item-btn:hover {
    background-color: #b71c1c;
    transform: scale(1.1);
}

.inventory-summary {
    background-color: var(--tertiary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row span:first-child {
    color: var(--text-secondary);
}

.summary-row span:last-child {
    color: var(--gold-color);
    font-weight: 600;
}

.clear-btn {
    width: 100%;
    margin-top: var(--spacing-md);
    padding: 0.6rem;
    background-color: var(--danger-color);
    border: 2px solid var(--danger-color);
    color: white;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background-color: transparent;
    color: var(--danger-color);
}

/* ===== MODAL (Corrigido) ===== */
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 95vh;
    overflow-y: auto;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);

    /* CORREÇÃO: Impede que o modal bloqueie cliques quando invisível */
    pointer-events: none;
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);

    /* CORREÇÃO: Reativa os cliques quando o modal abre */
    pointer-events: auto;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 49;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;

    /* CORREÇÃO: Impede que o fundo bloqueie cliques quando invisível */
    pointer-events: none;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;

    /* CORREÇÃO: Reativa os cliques (para fechar o modal) quando ativo */
    pointer-events: auto;
}

.modal-content {
    background: linear-gradient(135deg, var(--secondary-bg) 0%, var(--tertiary-bg) 100%);
    border: 3px solid var(--gold-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 1001;
    box-shadow: 0 0 30px rgba(218, 165, 32, 0.4);
}

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: none;
    border: none;
    color: var(--gold-color);
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close:hover {
    transform: rotate(90deg);
    color: var(--accent-light);
}

.modal-header {
    margin-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--gold-color);
    padding-bottom: var(--spacing-md);
}

.modal-title {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    color: var(--gold-color);
    margin-bottom: 0.5rem;
}

.modal-price {
    font-size: 1.1rem;
    color: var(--accent-light);
    font-weight: 600;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.modal-image-container {
    text-align: center;
    padding: var(--spacing-lg);
    background-color: var(--primary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
}

.modal-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-md);
}

.modal-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modal-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.modal-section h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    color: var(--gold-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.modal-section p {
    color: var(--text-secondary);
    line-height: 1.8;
}

.modal-stats {
    display: flex;
    justify-content: space-between;
    gap: 5px;
    width: 100%;
    margin-top: 10px;
    padding: 5px;
    background-color: var(--secondary-bg);
    border-radius: var(--radius-md);
    overflow-x: auto;
    /* Permite rolar lateralmente em telas muito pequenas */
}

.stat-box {
    flex: 1;
    /* Faz todos terem o mesmo tamanho base */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--tertiary-bg);
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    min-width: 0;
    /* Permite que o item encolha se faltar espaço */
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
    /* Impede que o título quebre linha */
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    /* Impede que o valor quebre linha */
    text-align: center;
}


.modal-stats::-webkit-scrollbar {
    height: 4px;
}

.modal-stats::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-add-item {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    padding: var(--spacing-md);
    background-color: var(--tertiary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
}

.modal-add-item label {
    color: var(--text-secondary);
    font-weight: 600;
}

.quantity-input {
    width: 60px;
    padding: 0.5rem;
    background-color: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Crimson Text', serif;
    text-align: center;
}

.quantity-input:focus {
    outline: none;
    border-color: var(--gold-color);
}

.add-item-btn {
    flex: 1;
    padding: 0.7rem;
    background-color: var(--accent-color);
    border: 2px solid var(--gold-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Cinzel', serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-item-btn:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 0 12px rgba(218, 165, 32, 0.4);
    transform: translateY(-2px);
}

/* ===== CUSTOMIZADOR ===== */
.customizer-section {
    background-color: var(--tertiary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
}

.customizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.customizer-header label {
    font-family: 'Cinzel', serif;
    color: var(--gold-color);
    font-weight: 600;
}

.quantity-select {
    padding: 0.5rem;
    background-color: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Crimson Text', serif;
    cursor: pointer;
}

.quantity-select:focus {
    outline: none;
    border-color: var(--gold-color);
}

.customizer-selectors {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.customizer-selectors select {
    padding: 0.5rem;
    background-color: var(--secondary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Crimson Text', serif;
}

.customizer-selectors select:focus {
    outline: none;
    border-color: var(--gold-color);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--secondary-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-color);
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
    .header-title {
        font-size: 2rem;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .modal-content {
        max-width: 90vw;
        max-height: 95vh;
        padding: var(--spacing-lg);
    }

    .container-grid {
        grid-template-columns: 1fr;
    }

    .inventory-container {
        margin-top: var(--spacing-lg);
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 1.5rem;
        letter-spacing: 1px;
    }

    .items-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .filter-group {
        flex-direction: column;
    }

    .filter-btn {
        width: 100%;
    }

    .modal-stats-container {
        grid-template-columns: 1fr;
    }
}

/* ===== BOTÕES FLUTUANTES (MOBILE/UX) ===== */
.floating-buttons {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 99;
    pointer-events: none;
    /* Permite clicar através da área vazia */
}

.float-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s, opacity 0.3s;
    opacity: 0;
    /* Escondido por padrão */
    transform: translateY(20px);
    visibility: hidden;
}

.float-btn.visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.float-btn:hover {
    background-color: var(--accent-hover);
    transform: scale(1.1);
}

/* Badge contador no botão do inventário */
.mobile-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger-color);
    color: white;
    font-size: 0.75rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid var(--secondary-bg);
}

/* Botão de fechar o inventário no mobile */
.inventory-close-mobile {
    display: none;
    /* Escondido no desktop */
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
}

/* ===== COMPORTAMENTO MOBILE ===== */
@media (max-width: 1023px) {

    /* O botão de inventário só aparece no mobile */
    #mobileInventoryBtn {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    /* Transforma o Aside em um Modal de tela cheia */
    .inventory-container {
        position: fixed;
        top: 0;
        right: -100%;
        /* Escondido para a direita */
        width: 100%;
        height: 100vh;
        z-index: 200;
        border-radius: 0;
        overflow-y: auto;
        transition: right 0.3s ease-in-out;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
        max-height: none;
        /* Remove limite de altura do desktop */
    }

    .inventory-container.active {
        right: 0;
        /* Desliza para a tela */
    }

    .inventory-close-mobile {
        display: block;
        /* Mostra o botão X */
    }

    /* Ajuste para a lista rolar bem no mobile */
    .inventory-list {
        max-height: calc(100vh - 250px);
    }
}

/* O botão de topo aparece em qualquer tela quando rola */
#backToTopBtn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
