/* ======================================================
   THEME VARIABLES
   ====================================================== */
:root {
    --value: 0; /* used only for stat progress bar */
    --bg: #f6f7fb;
    --surface: #ffffff;
    --text: #222;
    --muted: #666;

    --accent: #e3350d;
    --accent-soft: #fbd6cf;

    --border: #ddd;

    --radius: 14px;
    --radius-sm: 10px;

    --shadow-sm: 0 4px 10px rgba(0,0,0,0.08);
    --shadow-md: 0 8px 20px rgba(0,0,0,0.15);
}

html[data-theme="dark"] {
    --bg: #0f1115;
    --surface: #1a1d24;
    --text: #f2f2f2;
    --muted: #aaa;

    --accent: #ff4d4d;
    --accent-soft: #402020;

    --border: #2a2e38;

    --shadow-sm: 0 4px 12px rgba(0,0,0,0.6);
    --shadow-md: 0 10px 28px rgba(0,0,0,0.7);
}

/* ======================================================
   RESET & BASE
   ====================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ======================================================
   HEADER / FOOTER
   ====================================================== */
.header,
.footer {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.footer {
    border-top: 1px solid var(--border);
    border-bottom: none;
    padding: 16px;
}

/* Header refactor */
.header {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
    border-bottom: 1px solid var(--border);
}

/* ======================================================
   HEADER TABS
   ====================================================== */
.header-tabs {
    display: flex;
    justify-content: flex-start;
    gap: 24px;
    padding: 0 16px;
    background: var(--surface);
}

.header-tabs .tab {
    background: none;
    border: none;
    padding: 14px 4px;
    font-size: 15px;
    color: var(--muted);
    cursor: pointer;
    position: relative;
    box-shadow: none;
}

.header-tabs .tab:hover {
    color: var(--text);
}

.header-tabs .tab.active {
    color: var(--accent);
    font-weight: 600;
}

.header-tabs .tab.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
}

/* ======================================================
   MAIN LAYOUT
   ====================================================== */
.container {
    flex: 1;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px;

    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ======================================================
   PANELS
   ====================================================== */
.hidden {
    display: none;
}

/* ======================================================
   INPUTS & BUTTONS
   ====================================================== */
.field {
    display: flex;
    gap: 10px;
}

input {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 15px;
    background: var(--surface);
    color: var(--text);
}

input:focus {
    outline: none;
    border-color: var(--accent);
}

button {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 15px;

    box-shadow: var(--shadow-sm);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
    color: var(--text);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: translateY(1px);
    box-shadow: none;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.full-btn {
    width: 100%;
}

/* ======================================================
   PRIMARY ACTION BUTTON
   ====================================================== */
button.primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

button.primary:hover {
    background: color-mix(in srgb, var(--accent) 90%, #000 10%);
}

button.primary:active {
    background: color-mix(in srgb, var(--accent) 85%, #000 15%);
}

/* ======================================================
   THEME SWITCH (SLIDER)
   ====================================================== */
.theme-switch {
    position: absolute;
    right: 16px;
    width: 52px;
    height: 28px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
}

.slider::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    background: var(--surface);
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.theme-switch input:checked + .slider {
    background: var(--accent);
}

.theme-switch input:checked + .slider::before {
    transform: translateX(24px);
}

/* ======================================================
   STATUS
   ====================================================== */
.status {
    min-height: 24px;
}

.loading {
    color: var(--muted);
}

.error {
    color: var(--accent);
}

/* ======================================================
   RESULT / CARD
   ====================================================== */
.result {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.card {
    position: relative;
    width: 280px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px 20px 20px;
    text-align: center;

    box-shadow: var(--shadow-md);
    animation: fadeIn 0.2s ease-out;
    cursor : pointer;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card:active {
    transform: translateY(1px);
    box-shadow: none;
}

.card img {
    width: 160px;
    height: 160px;
    object-fit: contain;
}

.card-id,
.dex-id {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.card-id {
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 13px;
}

.card-name {
    margin-top: 8px;
    font-size: 20px;
    font-weight: 700;
    text-transform: capitalize;
}

.types {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 10px 0 14px;
    flex-wrap: wrap;
}

.card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.stat {
    background: color-mix(in srgb, var(--surface) 15%, var(--bg) 85%);
    border-radius: var(--radius-sm);
    padding: 10px 6px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 15px;
    font-weight: 600;
}

/* ======================================================
   POKÉMON TYPES (GLOBAL + COLOR MAP)
   ====================================================== */
.type {
    --type-color: var(--accent);

    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;

    color: #fff;
    background: var(--type-color);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
}

/* IMPORTANT: these MUST NOT be inside :root */
.type[data-type="normal"]   { --type-color: #A8A77A; }
.type[data-type="fire"]     { --type-color: #EE8130; }
.type[data-type="water"]    { --type-color: #6390F0; }
.type[data-type="electric"] { --type-color: #F7D02C; }
.type[data-type="grass"]    { --type-color: #7AC74C; }
.type[data-type="ice"]      { --type-color: #96D9D6; }
.type[data-type="fighting"] { --type-color: #C22E28; }
.type[data-type="poison"]   { --type-color: #A33EA1; }
.type[data-type="ground"]   { --type-color: #E2BF65; }
.type[data-type="flying"]   { --type-color: #A98FF3; }
.type[data-type="psychic"]  { --type-color: #F95587; }
.type[data-type="bug"]      { --type-color: #A6B91A; }
.type[data-type="rock"]     { --type-color: #B6A136; }
.type[data-type="ghost"]    { --type-color: #735797; }
.type[data-type="dragon"]   { --type-color: #6F35FC; }
.type[data-type="dark"]     { --type-color: #705746; }
.type[data-type="steel"]    { --type-color: #B7B7CE; }
.type[data-type="fairy"]    { --type-color: #D685AD; }

/* ======================================================
   NATIONAL DEX
   ====================================================== */

.dex-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow-sm);
}

.dex-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dex-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dex-label {
    font-size: 13px;
    color: var(--muted);
}

.dex-select,
.dex-filter {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
}

.dex-filter {
    min-width: 220px;
}

.dex-count {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

/* ======================================================
   FILTER TOGGLE + COLLAPSIBLE AREA
   ====================================================== */

.dex-filters-toggle {
    background: none;
    border: none;
    color: var(--accent);
    font-weight: 600;
    box-shadow: none;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.dex-filters-toggle:hover {
    background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface) 65%);
}

.dex-filters-extra {
    margin-top: 10px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;

    box-shadow: var(--shadow-sm);

    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dex-filters-extra.hidden {
    display: none;
}

/* Rows */
.dex-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Make min/max fields compact */
.dex-filters-extra #dex-min-id,
.dex-filters-extra #dex-max-id {
    width: 120px;
    min-width: 0;
}

/* ======================================================
   TYPE FILTER – PILL UX
   ====================================================== */

.dex-types-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Hide checkbox visuals but keep semantics */
.dex-types-filter input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Pills */
.dex-types-filter .type {
    cursor: pointer;
    user-select: none;

    opacity: 0.5;
    transform: scale(0.97);

    transition:
            opacity 0.15s ease,
            transform 0.15s ease,
            box-shadow 0.15s ease,
            filter 0.15s ease;
}

/* Selected state */
.dex-types-filter .type.active {
    opacity: 1;
    transform: scale(1);
    filter: saturate(1.05);
    box-shadow:
            0 0 0 2px var(--surface),
            0 0 0 4px var(--type-color);
}

/* Hover */
.dex-types-filter .type:hover {
    opacity: 0.85;
}

/* ======================================================
   TABLE
   ====================================================== */

.dex-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.dex-table {
    width: 100%;
    border-collapse: collapse;
}

.dex-table thead th {
    text-align: left;
    font-size: 13px;
    color: var(--muted);
    background: color-mix(in srgb, var(--surface) 85%, var(--bg) 15%);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    white-space: nowrap;
}

.dex-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

/* Row hover / press (keep effects subtle to avoid "jumping" layout) */
.dex-table tbody tr:hover {
    background: color-mix(in srgb, var(--surface) 90%, var(--accent-soft) 10%);
    cursor: pointer;
}

/* Column sizing */
.col-gen { width: 56px; }
.col-id { width: 70px; }
.col-art { width: 92px; }
.col-name { width: 200px; }

/* Artwork images */
.dex-art {
    width: 64px;
    height: 64px;
    object-fit: contain;
    display: block;
}

/* Text cells */
.dex-name {
    font-weight: 600;
    text-transform: capitalize;
}

.dex-gen {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.dex-types {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ======================================================
   PAGER
   ====================================================== */

.dex-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.dex-page-btn {
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
}

.dex-page-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.pager-ellipsis {
    color: var(--muted);
    padding: 0 4px;
}

.dex-page-btn.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.dex-page-info {
    font-size: 14px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* ======================================================
   RESPONSIVE
   ====================================================== */

@media (max-width: 480px) {
    .dex-filter {
        min-width: 0;
        width: 100%;
    }

    .dex-filters-extra {
        padding: 10px;
    }

    /* Keep toolbar tidy */
    .dex-toolbar {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .dex-toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    /* Existing behavior you had */
    .col-gen { display: none; }
    .dex-table tbody td:nth-child(1) { display: none; }
}


/* ======================================================
   OVERLAY / MODAL
   ====================================================== */
.overlay.hidden {
    display: none;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.pokemon-modal {
    background: var(--surface);
    color: var(--text);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);


    width: 90%;
    max-width: 360px;
    max-height: 85vh;
    overflow-y: auto;

    position: relative;
    animation: fadeIn 0.2s ease-out;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;

    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--accent);
}

.modal-content img {
    width: 180px;
    height: 180px;
    object-fit: contain;
    display: block;
    margin: 0 auto 8px;
}

.modal-content h2 {
    text-align: center;
    margin: 8px 0 6px;
    text-transform: capitalize;
}

.modal-content h3 {
    margin: 14px 0 6px;
    font-size: 14px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dex-flavor {
    font-size: 14px;
    color: var(--muted);
    margin: 10px 0 14px;
    line-height: 1.4;
}

.evolution {
    margin-top: 8px;
    font-size: 14px;
    text-align: center;
}

.evo-item {
    font-weight: 600;
    text-transform: capitalize;
}

/* ======================================================
   MODAL SCROLLBAR
   ====================================================== */

/* Firefox */
.pokemon-modal {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
}

/* Chromium / Safari */
.pokemon-modal::-webkit-scrollbar {
    width: 8px;
}

.pokemon-modal::-webkit-scrollbar-track {
    background: transparent;
}

.pokemon-modal::-webkit-scrollbar-thumb {
    background: color-mix(
            in srgb,
            var(--muted) 40%,
            transparent
    );
    border-radius: 999px;
    border: 2px solid transparent; /* creates inner padding */
    background-clip: padding-box;
}

.pokemon-modal::-webkit-scrollbar-thumb:hover {
    background: color-mix(
            in srgb,
            var(--accent) 55%,
            transparent
    );
}


/* ======================================================
   STAT BARS
   ====================================================== */
.stat-bar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.stat-bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.stat-track {
    height: 8px;
    background: color-mix(in srgb, var(--surface) 20%, var(--bg) 80%);
    border-radius: 999px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    width: calc(var(--value) * 1%);
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.3s ease;
}


/* ======================================================
   ANIMATION
   ====================================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ======================================================
   RESPONSIVE
   ====================================================== */
@media (max-width: 480px) {
    .field {
        flex-direction: column;
    }

    .dex-filter {
        min-width: 0;
        width: 100%;
    }

    .col-gen { display: none; }
    .dex-table tbody td:nth-child(1) { display: none; }
}