/* ========================================
   PokeWeak — Main Stylesheet
   ======================================== */

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1c2a4a;
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0c0;
    --text-muted: #6c6c8a;
    --accent: #7b2ff7;
    --accent-hover: #a855f7;
    --border: #2a2a4a;
    --shadow: rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 50px;
    --transition: 0.25s ease;
    --max-width: 1200px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(123, 47, 247, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(192, 132, 252, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

#app {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
}

img {
    max-width: 100%;
    height: auto;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
    color: inherit;
}

[hidden] {
    display: none !important;
}

/* ---------- Header ---------- */
.header {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
    position: relative;
}

/* ---------- Lang Switcher ---------- */
.lang-switcher {
    position: absolute;
    top: 1.25rem;
    right: 1rem;
    display: flex;
    gap: 0.35rem;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 2px solid var(--border);
    transition: all var(--transition);
    cursor: pointer;
    letter-spacing: 0.5px;
}

.lang-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 10px rgba(123, 47, 247, 0.4);
}

.header__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.header__logo h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #a0a0c0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__logo .highlight {
    background: linear-gradient(135deg, #7b2ff7 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ---------- Section Titles ---------- */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.subsection-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* ---------- Type Grid (Selector) ---------- */
.type-selector {
    padding: 1rem 0 2rem;
}

.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
    max-width: 900px;
    margin: 0 auto;
}

.type-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: capitalize;
    color: #fff;
    border: 2px solid transparent;
    transition: all var(--transition);
    box-shadow: 0 2px 8px var(--shadow);
    position: relative;
    overflow: hidden;
}

.type-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    pointer-events: none;
}

.type-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px var(--shadow);
    filter: brightness(1.15);
}

.type-btn:active {
    transform: translateY(0);
}

.type-btn.active {
    border-color: #fff;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.type-btn__icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ---------- Type Badge ---------- */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
    color: #fff;
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid transparent;
}

.type-badge:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

.type-badge.active {
    border-color: #fff;
    box-shadow: 0 0 12px rgba(255,255,255,0.3);
}

.type-badge__icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ---------- Results Section ---------- */
.results {
    padding: 2rem 0;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.weakness-section,
.resistance-section,
.immunity-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.weakness-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* ---------- Pokemon Filter ---------- */
.pokemon-filter {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.filter-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-clear {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(233, 69, 96, 0.2);
    color: var(--accent);
    font-size: 0.9rem;
    transition: all var(--transition);
}

.btn-clear:hover {
    background: var(--accent);
    color: #fff;
}

/* ---------- Pokemon Section ---------- */
.pokemon-count {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.pokemon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

/* ---------- Pokemon Card ---------- */
.pokemon-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.pokemon-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60%;
    border-radius: var(--radius) var(--radius) 50% 50%;
    opacity: 0.08;
    pointer-events: none;
}

.pokemon-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px var(--shadow);
    border-color: rgba(255, 255, 255, 0.1);
}

.pokemon-card__id {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.pokemon-card__sprite {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
}

.pokemon-card:hover .pokemon-card__sprite {
    transform: scale(1.15);
}

.pokemon-card__name {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: capitalize;
    margin-top: 0.25rem;
    color: var(--text-primary);
}

.pokemon-card__types {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    margin-top: 0.5rem;
}

.pokemon-card__type-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: inline-block;
}

/* ---------- Load More ---------- */
.load-more-container {
    text-align: center;
    margin-top: 2rem;
}

.btn-load-more {
    padding: 0.75rem 2.5rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 1rem;
    font-weight: 600;
    transition: all var(--transition);
}

.btn-load-more:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.3);
}

/* ---------- Loading Spinner ---------- */
.loading {
    text-align: center;
    padding: 3rem 1rem;
}

.loading p {
    color: var(--text-secondary);
    margin-top: 1rem;
}

.pokeball-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto;
    border: 4px solid var(--accent);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

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

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    z-index: 10;
    transition: all var(--transition);
}

.modal__close:hover {
    background: var(--accent);
}

.modal__content {
    padding: 2rem;
}

.modal__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.modal__sprite {
    width: 150px;
    height: 150px;
    image-rendering: pixelated;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
}

.modal__name {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: capitalize;
    margin-top: 0.5rem;
}

.modal__id {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.modal__types {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.modal__stats {
    margin-top: 1.5rem;
}

.modal__stats h4 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.stat-row__label {
    width: 40px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: right;
}

.stat-row__bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.stat-row__fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.stat-row__value {
    width: 35px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal__info {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.info-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    text-align: center;
}

.info-item__label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.info-item__value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ---------- Back to Top Button ---------- */
.btn-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.4);
    z-index: 500;
    transition: all var(--transition);
}

.btn-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(123, 47, 247, 0.5);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .header__logo h1 {
        font-size: 2rem;
    }

    .header__tagline {
        font-size: 0.95rem;
    }

    .section-title {
        font-size: 1.25rem;
    }

    .type-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 0.6rem;
    }

    .type-btn {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    .type-btn__icon {
        width: 20px;
        height: 20px;
    }

    .pokemon-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.75rem;
    }

    .pokemon-card__sprite {
        width: 80px;
        height: 80px;
    }

    .modal {
        max-width: 100%;
        margin: 0;
        border-radius: var(--radius) var(--radius) 0 0;
        max-height: 85vh;
    }

    .modal-overlay {
        align-items: flex-end;
    }

    .btn-top {
        bottom: 1rem;
        right: 1rem;
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 480px) {
    .type-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .type-btn {
        padding: 0.5rem;
        font-size: 0.8rem;
        gap: 0.3rem;
    }

    .pokemon-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .weakness-badges {
        gap: 0.4rem;
    }

    .type-badge {
        font-size: 0.8rem;
        padding: 0.35rem 0.7rem;
    }
}

/* ---------- Footer ---------- */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* ---------- Type Colors ---------- */
.type-normal    { background-color: #a8a878; }
.type-fire      { background-color: #f08030; }
.type-water     { background-color: #6890f0; }
.type-electric  { background-color: #f8d030; color: #333; }
.type-grass     { background-color: #78c850; }
.type-ice       { background-color: #98d8d8; color: #333; }
.type-fighting  { background-color: #c03028; }
.type-poison    { background-color: #a040a0; }
.type-ground    { background-color: #e0c068; color: #333; }
.type-flying    { background-color: #a890f0; }
.type-psychic   { background-color: #f85888; }
.type-bug       { background-color: #a8b820; color: #333; }
.type-rock      { background-color: #b8a038; }
.type-ghost     { background-color: #705898; }
.type-dragon    { background-color: #7038f8; }
.type-dark      { background-color: #705848; }
.type-steel     { background-color: #b8b8d0; color: #333; }
.type-fairy     { background-color: #ee99ac; color: #333; }
