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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    display: flex;
    height: 100vh;
    max-width: 1800px;
    margin: 0 auto;
    overflow: hidden;
}

/* Filters Section */
.filters-section {
    width: 20%;
    min-width: 280px;
    background: white;
    padding: 2rem 1.5rem;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    height: 100vh;
    position: sticky;
    top: 0;
}

.filters-section h1 {
    color: #667eea;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #555;
    font-size: 0.9rem;
}

.dropdown-container {
    position: relative;
}

.filter-input {
    width: 100%;
    padding: 0.75rem;
    padding-right: 2.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
}

.filter-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.clear-input {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-60%);
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    transition: color 0.2s ease;
    z-index: 10;
}

.clear-input:hover {
    color: #ff6b6b;
}

.dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.dropdown-list.show {
    display: block;
}

.dropdown-item {
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: #f5f5f5;
}

.dropdown-item.selected {
    background: #667eea;
    color: white;
}

.clear-btn {
    width: 100%;
    padding: 0.75rem;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.clear-btn:hover {
    background: #ee5a52;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 107, 107, 0.3);
}

/* Move Categories Section */
.category-toggle {
    width: 100%;
    padding: 0.75rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.category-toggle:hover {
    background: #5568d3;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.category-toggle.expanded .toggle-icon {
    transform: rotate(180deg);
}

.categories-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #f9f9f9;
    border-radius: 8px;
}

.categories-container.show {
    max-height: 500px;
    overflow-y: auto;
    padding: 0.5rem;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    margin: 0.25rem 0;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.category-item:hover {
    background: #fff;
}

.category-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin-right: 0.75rem;
    accent-color: #667eea;
}

.category-item label {
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
    margin: 0;
    flex: 1;
}

/* Results Section */
.results-section {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

#results-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    margin-top: 1rem;
    font-size: 1.1rem;
}

.error {
    background: #ff6b6b;
    color: white;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.hidden {
    display: none !important;
}

.results-header {
    background: white;
    padding: 1.5rem;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.results-header h2 {
    color: #333;
    margin-bottom: 0.5rem;
}

.results-count {
    color: #666;
    font-size: 0.9rem;
}

.table-container {
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#pokemon-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#pokemon-table thead {
    background: #667eea;
    color: white;
    display: block;
    width: 100%;
}

#pokemon-table th {
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.2s ease;
}

#pokemon-table th:hover {
    background: #5568d3;
}

#pokemon-table th[data-sort="sprite"] {
    cursor: default;
}

#pokemon-table th[data-sort="sprite"]:hover {
    background: #667eea;
}

.sort-icon {
    display: inline-block;
    font-size: 0.7rem;
    margin-top: 0.25rem;
}

.sort-icon::after {
    content: '⇅';
    opacity: 0.5;
}

th.sort-asc .sort-icon::after {
    content: '▲';
    opacity: 1;
}

th.sort-desc .sort-icon::after {
    content: '▼';
    opacity: 1;
}

#pokemon-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

#pokemon-table tbody tr {
    transition: background 0.2s ease;
}

#pokemon-table tbody {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    width: 100%;
    position: relative;
}

#pokemon-table thead tr,
#pokemon-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* Column width allocation */
#pokemon-table th:nth-child(1),
#pokemon-table td:nth-child(1) {
    width: 80px; /* Sprite */
}

#pokemon-table th:nth-child(2),
#pokemon-table td:nth-child(2) {
    width: 150px; /* Name - increased width */
}

#pokemon-table th:nth-child(3),
#pokemon-table td:nth-child(3) {
    width: 100px; /* Type */
}

/* Stat columns - reduced width for numbers */
#pokemon-table th:nth-child(4),
#pokemon-table td:nth-child(4),
#pokemon-table th:nth-child(5),
#pokemon-table td:nth-child(5),
#pokemon-table th:nth-child(6),
#pokemon-table td:nth-child(6),
#pokemon-table th:nth-child(7),
#pokemon-table td:nth-child(7),
#pokemon-table th:nth-child(8),
#pokemon-table td:nth-child(8),
#pokemon-table th:nth-child(9),
#pokemon-table td:nth-child(9) {
    width: 60px; /* Stats: HP, ATK, DEF, SPATK, SPDEF, SPD */
}

#pokemon-table th:nth-child(10),
#pokemon-table td:nth-child(10) {
    width: 70px; /* BST */
}

#pokemon-table tbody tr:hover {
    background: #f9f9f9;
}

/* Disable pointer events on headers when no data */
#pokemon-table.disabled-sort th {
    cursor: default !important;
    pointer-events: none;
}

#pokemon-table.disabled-sort th:hover {
    background: #667eea !important;
}

.pokemon-sprite {
    width: 60px;
    height: 60px;
    image-rendering: pixelated;
}

.pokemon-name {
    font-weight: 600;
    text-transform: capitalize;
}

.type-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
}

.type-column {
    line-height: 1.8;
    white-space: nowrap;
}

.type-icon {
    width: 50px;
    height: 20px;
    vertical-align: middle;
}

/* Pokemon Type Colors */
.type-normal { background: #A8A878; }
.type-fire { background: #F08030; }
.type-water { background: #6890F0; }
.type-electric { background: #F8D030; }
.type-grass { background: #78C850; }
.type-ice { background: #98D8D8; }
.type-fighting { background: #C03028; }
.type-poison { background: #A040A0; }
.type-ground { background: #E0C068; }
.type-flying { background: #A890F0; }
.type-psychic { background: #F85888; }
.type-bug { background: #A8B820; }
.type-rock { background: #B8A038; }
.type-ghost { background: #705898; }
.type-dragon { background: #7038F8; }
.type-dark { background: #705848; }
.type-steel { background: #B8B8D0; }
.type-fairy { background: #EE99AC; }

.stat-cell {
    font-weight: 600;
    text-align: center;
}

.bst-cell {
    font-weight: 700;
    text-align: center;
    color: #667eea;
}

.no-results {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 5;
}

.no-results p {
    font-size: 1.2rem;
    color: #666;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 5;
}

.empty-state p {
    font-size: 1.2rem;
    color: #667eea;
    font-weight: 500;
}

/* Responsive Design */
.mobile-filter-toggle {
    display: none;
    width: 100%;
    padding: 1rem;
    background: #667eea;
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mobile-header-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.mobile-toggle-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mobile-toggle-text {
    font-size: 1rem;
}

.mobile-toggle-icon {
    transition: transform 0.3s ease;
    font-size: 1rem;
}

.mobile-filter-toggle.expanded .mobile-toggle-icon {
    transform: rotate(180deg);
}

.desktop-header {
    display: block;
}

@media (max-width: 1200px) {
    .filters-section {
        width: 25%;
    }
}

@media (max-width: 768px) {
    .mobile-filter-toggle {
        display: flex;
    }

    .desktop-header {
        display: none;
    }

    .container {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }

    .filters-section {
        width: 100%;
        min-width: auto;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        position: relative;
        height: auto;
        padding: 0;
    }

    .filters-section.show {
        max-height: 80vh;
        overflow-y: auto;
        padding: 2rem 1.5rem;
    }

    .results-section {
        padding: 1rem;
        height: auto;
        overflow: visible;
    }

    #pokemon-table {
        font-size: 0.7rem;
    }

    #pokemon-table th {
        padding: 0.5rem 0.25rem;
        font-size: 0.65rem;
        line-height: 1.2;
    }

    #pokemon-table td {
        padding: 0.5rem 0.25rem;
    }

    /* Hide sprite and BST columns on mobile */
    .sprite-col,
    .bst-col,
    .sprite-cell,
    .bst-cell {
        display: none;
    }

    .pokemon-name {
        font-size: 0.75rem;
    }

    .type-badge {
        padding: 0.15rem 0.3rem;
        font-size: 0.55rem;
    }

    .type-column {
        line-height: 1.5;
    }

    .stat-cell {
        font-size: 0.7rem;
    }

    .results-header h2 {
        font-size: 1.2rem;
    }

    .results-count {
        font-size: 0.8rem;
    }

    .pokemon-sprite {
        width: 40px;
        height: 40px;
    }

    /* Mobile column widths */
    #pokemon-table th:nth-child(1),
    #pokemon-table td:nth-child(1) {
        width: 0; /* Sprite hidden */
    }

    #pokemon-table th:nth-child(2),
    #pokemon-table td:nth-child(2) {
        width: 90px; /* Name */
    }

    #pokemon-table th:nth-child(3),
    #pokemon-table td:nth-child(3) {
        width: 60px; /* Type */
    }

    /* Mobile stat columns */
    #pokemon-table th:nth-child(4),
    #pokemon-table td:nth-child(4),
    #pokemon-table th:nth-child(5),
    #pokemon-table td:nth-child(5),
    #pokemon-table th:nth-child(6),
    #pokemon-table td:nth-child(6),
    #pokemon-table th:nth-child(7),
    #pokemon-table td:nth-child(7),
    #pokemon-table th:nth-child(8),
    #pokemon-table td:nth-child(8),
    #pokemon-table th:nth-child(9),
    #pokemon-table td:nth-child(9) {
        width: 45px; /* Stats */
    }

    #pokemon-table th:nth-child(10),
    #pokemon-table td:nth-child(10) {
        width: 0; /* BST hidden */
    }
}
