/* ================================
   XP Calculator
   Level bar, sub-tabs, controls,
   food table, my list, tooltips
   ================================ */

/* ── CLS Prevention — reserve space until JS hydrates ── */
#xpContent.active:not(.hydrated) {
    min-height: 1200px;
}

#xpLevelBar {
    min-height: 52px;
    padding-bottom: 1.5rem;
}

/* ── Level Bar (filled box) ── */
.xp-level-bar {
    position: relative;
    overflow: hidden;
    padding: 0.75rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
}

/* Background fill layers */
.xp-level-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: color-mix(in srgb, var(--green) 25%, transparent);
    transition: width 0.4s ease;
    pointer-events: none;
    z-index: 0;
}

.xp-level-overfill {
    position: absolute;
    top: 0;
    height: 100%;
    width: 0;
    background: color-mix(in srgb, var(--negative) 30%, transparent);
    transition: width 0.4s ease, left 0.4s ease;
    pointer-events: none;
    z-index: 0;
}

/* ── Level Ruler ── */
.xp-ruler {
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 4px;
    z-index: 1;
    display: flex;
    height: 18px;
    overflow: visible;
}

.xp-ruler-segment {
    position: relative;
    flex-shrink: 0;
    height: 100%;
}

.xp-ruler-tick {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 1px;
    height: 6px;
    background: var(--muted);
    opacity: 0.5;
}

.xp-ruler-tick.mid {
    height: 10px;
    opacity: 0.65;
}

.xp-ruler-tick.major {
    height: 14px;
    width: 1.5px;
    opacity: 0.8;
}

.xp-ruler-label {
    position: absolute;
    right: 0;
    top: -5px;
    transform: translateX(50%);
    font-size: 0.55rem;
    color: var(--muted);
    opacity: 0.7;
    white-space: nowrap;
    line-height: 1;
    pointer-events: none;
}

.xp-ruler-label.mid {
    font-weight: 500;
    opacity: 0.78;
}

.xp-ruler-label.major {
    font-weight: 700;
    color: var(--text);
    opacity: 0.92;
}

.xp-ruler-label.edge-left {
    right: auto;
    left: 0;
    transform: none;
}

.xp-ruler-label.edge-right {
    right: 0;
    transform: none;
    text-align: right;
}

/* Info block (XP needed + remaining) — centered below controls */
.xp-level-info {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-top: 0.2rem;
}

.xp-needed-display {
    display: block;
    font-weight: 600;
    color: var(--green);
    font-size: 0.82rem;
}

.xp-remaining-display {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    min-height: 1em;
}

/* Level input controls row */
.xp-level-controls {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
}

.xp-level-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.xp-level-input-group label {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.xp-level-input {
    width: 68px;
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
}

.xp-level-arrow {
    font-size: 1.3rem;
    color: var(--muted);
}

/* Progress bar (still used in My List summary) */
.xp-progress-bar {
    display: flex;
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.3rem;
}

.xp-progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.xp-progress-overfill {
    height: 100%;
    background: var(--negative);
    border-radius: 0 3px 3px 0;
    transition: width 0.3s ease;
}

/* ── Sub-tabs (within XP calc) ── */
/* Sub-tabs scroll wrapper */
.xp-sub-tabs-wrapper {
    position: relative;
    margin-bottom: 0.75rem;
}

.xp-sub-tabs {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
}
.xp-sub-tabs::-webkit-scrollbar { display: none; }

.xp-sub-tab,
.xp-show-all-btn,
.xp-season-btn {
    flex-shrink: 0;
}

/* Fade gradients */
.xp-sub-tabs-wrapper::before,
.xp-sub-tabs-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 28px;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.xp-sub-tabs-wrapper::before {
    left: 0;
    background: linear-gradient(to right, var(--bg), transparent);
}
.xp-sub-tabs-wrapper::after {
    right: 0;
    background: linear-gradient(to left, var(--bg), transparent);
}
.xp-sub-tabs-wrapper.can-scroll-left::before { opacity: 1; }
.xp-sub-tabs-wrapper.can-scroll-right::after { opacity: 1; }

/* Arrow buttons */
.xp-sub-tabs-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 22px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--card);
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.xp-sub-tabs-arrow:hover {
    background: var(--tag-bg);
    color: var(--text);
}
.xp-sub-tabs-arrow-left { left: 1px; }
.xp-sub-tabs-arrow-right { right: 1px; }
.xp-sub-tabs-wrapper.can-scroll-left .xp-sub-tabs-arrow-left { display: flex; }
.xp-sub-tabs-wrapper.can-scroll-right .xp-sub-tabs-arrow-right { display: flex; }

.xp-sub-tab {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px 6px 0 0;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: none;
}

.xp-sub-tab.active {
    background: var(--card);
    color: var(--text);
    font-weight: 600;
}

.xp-show-all-btn {
    margin-left: 0.35rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    font-size: 0.8rem;
}

.xp-show-all-btn.active {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

/* ── Season Selector ── */
.xp-season-selector {
    display: flex;
    gap: 0.2rem;
    margin-left: auto;
    align-items: center;
}

.xp-season-btn {
    padding: 0.25rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 34px;
}

.xp-season-btn:hover {
    background: var(--card);
}

.xp-season-btn.active {
    background: #4a7c3f;
    color: #fff;
    border-color: #3a6830;
    font-weight: 600;
}

.xp-season-btn-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

#xpClearAllBtn {
    color: var(--negative);
    border-color: var(--negative);
}

#xpClearAllBtn:hover {
    background: var(--negative);
    color: white;
}

.xp-sub-content {
    display: none;
}

.xp-sub-content.active {
    display: block;
}

/* ── Food Table ── */
.xp-table-wrapper {
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

.xp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.xp-table th {
    padding: 0.4rem 0.5rem;
    text-align: right;
    border-bottom: 2px solid var(--border);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.78rem;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.xp-table th:first-child,
.xp-table td:first-child {
    text-align: left;
}

.xp-table th.sorted {
    color: var(--green);
    font-weight: 700;
}

.xp-table td.sorted-col {
    font-weight: 600;
}

.xp-table th .sort-arrow {
    font-size: 0.7rem;
    margin-left: 0.2rem;
}

.xp-table td {
    padding: 0.35rem 0.5rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.xp-table tbody tr {
    background: rgba(255, 253, 248, 0.20);
}

.xp-table tbody tr:nth-child(even) {
    background: rgba(245, 240, 229, 0.25);
}

.xp-table tbody tr:hover {
    background: #ede6d6;
}

.xp-food-name-cell {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.xp-fish-name-text {
    display: inline-block;
}

.xp-fish-tier-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    border: 1px solid transparent;
}

.xp-fish-tier-badge.tier-basic {
    color: #4a7c3f;
    background: rgba(74,124,63,0.12);
    border-color: rgba(74,124,63,0.2);
}

.xp-fish-tier-badge.tier-advanced {
    color: #4a7090;
    background: rgba(74,112,144,0.12);
    border-color: rgba(74,112,144,0.2);
}

.xp-fish-tier-badge.tier-expert {
    color: #b8860b;
    background: rgba(184,134,11,0.12);
    border-color: rgba(184,134,11,0.22);
}

.xp-fish-season-icons {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.xp-fish-season-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.xp-food-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.xp-th-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 0.15rem;
}

.xp-add-btn {
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    font-size: 0.75rem;
}

.xp-add-btn:hover {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

/* ── Info Notices ── */
.xp-info-panel {
    margin-bottom: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.xp-info-notice {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 600;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0;
    background: rgba(214,203,184,0.06);
    border-radius: 0;
    border-left: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.xp-inline-warning {
    color: #c0392b;
    font-weight: 700;
}

.xp-info-notice + .xp-info-notice {
    border-top: 1px solid var(--border);
}


.xp-info-value {
    color: #c0392b;
}

.xp-info-separator {
    color: var(--muted);
    opacity: 0.8;
}

.xp-info-inline-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    image-rendering: pixelated;
}

.xp-info-help {
    margin-left: auto;
    font-size: 0.72rem;
    color: #7a9dc4;
    opacity: 0.9;
}

.xp-info-emphasis {
    color: var(--text);
}

.xp-toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    white-space: nowrap;
}

.xp-toggle {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.xp-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.xp-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 18px;
    transition: background 0.2s;
}

.xp-toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.xp-toggle input:checked + .xp-toggle-slider {
    background: var(--green);
}

.xp-toggle input:checked + .xp-toggle-slider::before {
    transform: translateX(16px);
}

.xp-info-notice input[type="number"] {
    width: 80px;
    padding: 0.15rem 0.3rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.78rem;
    text-align: center;
}

/* ── My List ── */

.xp-mylist-add-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--green);
    border-radius: 6px;
    background: var(--bg);
    color: var(--green);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.xp-mylist-add-btn:hover {
    background: var(--green);
    color: white;
}

/* ── Food Picker (custom dropdown with icons) ── */
.xp-food-picker {
    display: inline-block;
    position: relative;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.xp-food-picker-search {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--green);
    border-radius: 6px 6px 0 0;
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    width: 220px;
    outline: none;
}

.xp-food-picker-search:focus {
    border-color: var(--green);
}

.xp-food-picker-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 220px;
    max-height: 280px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--green);
    border-top: none;
    border-radius: 0 0 6px 6px;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.xp-food-picker.open-up .xp-food-picker-search {
    border-radius: 0 0 6px 6px;
}

.xp-food-picker.open-up .xp-food-picker-list {
    top: auto;
    bottom: 100%;
    border-top: 1px solid var(--green);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

.xp-food-picker-group {
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

.xp-food-picker-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.xp-food-picker-item:last-child {
    border-bottom: none;
}

.xp-food-picker-item:hover {
    background: color-mix(in srgb, var(--green) 12%, transparent);
}

.xp-food-picker-item .xp-food-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.xp-mylist-table .xp-mylist-qty-input {
    width: 55px;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    text-align: center;
}

.xp-qty-food-note {
    color: var(--info);
    font-weight: 600;
    font-size: 0.82rem;
}

.xp-mylist-table td {
    vertical-align: middle;
}

.xp-mylist-remove {
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--negative);
    cursor: pointer;
    font-size: 0.78rem;
}

.xp-mylist-remove:hover {
    background: var(--negative);
    color: white;
}

.xp-mylist-empty {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.xp-mylist-total-row td {
    border-top: 2px solid var(--border);
    border-bottom: none;
    font-weight: 600;
    padding-top: 0.5rem;
}

.xp-mylist-total-highlight {
    font-size: 1.05rem;
    font-weight: 700;
}

.xp-mylist-add-food {
    padding: 0.5rem 0;
    position: relative;
}

/* (xp-mylist-remaining removed — remaining display is now in the level bar) */

/* ── XP Tooltip Additions ── */
.xp-tooltip-indent {
    padding-left: 1rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.xp-tooltip-indent .boost-tooltip-name::before {
    content: '\2514\00A0';
    color: var(--border);
}

.xp-category-header-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 0.3rem;
}

.xp-guaranteed-badge {
    color: var(--positive);
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .xp-level-bar {
        padding: 0.5rem 0.75rem;
    }

    .xp-level-controls {
        gap: 0.75rem;
    }

    .xp-table {
        font-size: 0.78rem;
    }

    .xp-table th,
    .xp-table td {
        padding: 0.3rem 0.35rem;
    }

    .xp-mylist-table .xp-mylist-qty-input {
        width: 45px;
    }
}
