/* Base styles */
* {
    font-family: Arial, sans-serif;
}

/* Global box sizing */
*, *:before, *:after {
    box-sizing: border-box;
}

/* Prevent horizontal scroll on body/html */
html, body {
    max-width: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* Container for all content */
.content {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

/* Update the top navigation styles */
.top-nav {
    display: flex;
    justify-content: space-around;
    background: var(--tg-theme-secondary-bg-color);
    padding: 12px;
    /* Remove negative margins */
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    /* Add container styles */
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Update the content container */
.content {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
    /* Add padding to offset the header */
    padding: 0 8px; /* Add horizontal padding */
}

/* Update nav link styles to ensure they fit */
.nav-link {
    color: var(--tg-theme-hint-color);
    text-decoration: none;
    padding: 8px 12px; /* Slightly reduce padding */
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    text-align: center;
    flex: 1; /* Make links take equal space */
    margin: 0 4px; /* Add small margin between links */
}

/* Ensure nav links container stays within bounds */
.nav-link.active {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    /* No changes needed, inherits box-sizing */
}

/* Update all content below nav */
.content > *:not(.top-nav) {
    margin-top: 16px;
}

/* Collection card styles - renamed to avoid conflicts with filter */
.staked-collection-stats {
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
    padding: 16px;
    margin: 0 16px 16px 16px;
    position: relative;
}

.staked-collection-header {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

/* Ensure collection preview doesn't conflict with filter preview */
.staked-collection-preview {
    width: 50px;
    height: 50px;
    position: relative;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
}

.staked-collection-info {
    flex: 1;
    min-width: 0;
}

.staked-collection-title-row {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.staked-collection-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--tg-theme-text-color);
    text-decoration: none;
}

.staked-collection-title:hover {
    text-decoration: underline;
}

.details-btn {
    color: #2F80ED;
    text-decoration: none;
    border: none;
    background: none;
    padding: 0;
    font-size: 14px;
}

/* Stats badges */
.stats-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stats-badge {
    padding: 4px 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    position: relative;
    cursor: pointer;
}

.stats-badge.price {
    background: rgba(157, 234, 190, 0.2);
}

.stats-badge.price .stats-badge-icon,
.stats-badge.price .stats-badge-value {
    color: rgb(75, 181, 120);
}

.stats-badge.points {
    background: rgba(144, 202, 249, 0.2);
}

.stats-badge.points .stats-badge-icon,
.stats-badge.points .stats-badge-value {
    color: rgb(66, 165, 245);
}

.stats-badge.count {
    background: rgba(255, 183, 77, 0.2);
}

.stats-badge.count .stats-badge-icon,
.stats-badge.count .stats-badge-value {
    color: rgb(255, 152, 0);
}

.stats-badge.supply {
    background: rgba(240, 98, 146, 0.15);
}

.stats-badge.supply .stats-badge-icon,
.stats-badge.supply .stats-badge-value {
    color: rgb(240, 98, 146);
}

.stats-badge.locked {
    background: rgba(158, 158, 158, 0.2);
}

.stats-badge.locked .stats-badge-icon,
.stats-badge.locked .stats-badge-value {
    color: rgb(117, 117, 117);
}

.stats-badge.global-price {
    background: rgba(147, 112, 219, 0.2);
}

.stats-badge.global-price .stats-badge-icon,
.stats-badge.global-price .stats-badge-value {
    color: rgb(147, 112, 219);
}

/* List section */
.list-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Control layout */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

/* Slider container */
.slider-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.control-label {
    font-size: 14px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 4px;
}

/* Price input container with auto toggle */
.price-container {
    position: relative;
    display: flex;
    align-items: center;
}

.price-input {
    width: 70px;
    height: 32px;
    padding: 4px 8px;  /* Reduced padding */
    border: 1px solid var(--tg-theme-hint-color);
    border-radius: 8px;
    font-size: 16px;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    -moz-appearance: textfield; /* Remove default spinners in Firefox */
}

/* Amount input styling */
.amount-input {
    width: 70px;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid var(--tg-theme-hint-color);
    border-radius: 8px;
    font-size: 16px;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    text-align: right;
    -moz-appearance: textfield; /* Remove default spinners in Firefox */
}

/* Hide default spinners in Chrome, Safari, Edge for amount input */
.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Auto toggle container positioning */
.auto-list-container {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    color: var(--tg-theme-text-color);
    font-size: 14px;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;  /* Slightly adjusted width */
    height: 20px;  /* Kept smaller height */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--tg-theme-hint-color);
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;  /* Kept smaller size */
    width: 16px;   /* Kept smaller size */
    left: 2px;
    bottom: 2px;
    background-color: var(--tg-theme-bg-color);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--tg-theme-button-color);
}

input:checked + .slider:before {
    transform: translateX(20px);  /* Adjusted for new width */
}

/* Range input styles */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 2px;
    background: var(--tg-theme-hint-color);
    border-radius: 1px;
    margin: 8px 0;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--tg-theme-button-color);
    cursor: pointer;
    border: none;
    margin-top: -7px;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--tg-theme-button-color);
    cursor: pointer;
    border: none;
}

.slider-value {
    font-size: 14px;
    color: var(--tg-theme-text-color);
    min-width: 24px;
    text-align: right;
    margin-left: 8px;
}

/* Action button */
.action-button {
    margin-top: 8px;
    width: 100%;
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* No collections state */
.no-collections {
    text-align: center;
    padding: 32px 16px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
    margin: 16px;
}

.no-collections p {
    color: var(--tg-theme-text-color);
    font-size: 16px;
    margin-bottom: 16px;
}

.no-collections .deposit-btn {
    min-width: 160px;
    margin: 0 auto;
}

/* Tooltip styles */
.stats-badge {
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--tg-theme-bg-color);
    border: 1px solid var(--tg-theme-hint-color);
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    color: var(--tg-theme-text-color);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    pointer-events: none;
}

/* Show tooltip states */
@media (hover: hover) {
    .stats-badge:hover .tooltip-content {
        opacity: 1;
        visibility: visible;
    }
}

.stats-badge.tooltip-active .tooltip-content {
    opacity: 1;
    visibility: visible;
}

.stats-badge.tooltip-active {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Add bottom padding to container */
#collections-list {
    padding-bottom: 120px; /* Space for keyboard */
    overflow-y: auto;
}

/* Update tooltip positioning */
.tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--tg-theme-bg-color);
    border: 1px solid var(--tg-theme-hint-color);
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    color: var(--tg-theme-text-color);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    pointer-events: none;
    /* Ensure tooltip stays within viewport */
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure tooltips don't go off-screen on the sides */
.stats-badge {
    position: relative;
}

.stats-badge:first-child .tooltip-content {
    left: 0;
    transform: none;
}

.stats-badge:last-child .tooltip-content {
    left: auto;
    right: 0;
    transform: none;
}

/* Make stats badges wrap better on small screens */
.stats-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -4px; /* Negative margin to offset padding */
    padding: 4px; /* Padding to prevent clipping of shadows */
}

.stats-badge {
    flex: 0 1 auto;
    min-width: 0; /* Allow badges to shrink */
}

/* Ensure collection card stays within bounds */
.staked-collection-stats {
    margin: 0 16px 16px 16px;
    max-width: calc(100% - 32px); /* Account for margins */
    box-sizing: border-box;
    overflow: hidden; /* Prevent content from spilling out */
}

.price-input::-webkit-inner-spin-button,
.price-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Center the slider dot vertically */
input[type="range"]::-webkit-slider-thumb {
    margin-top: -2px; /* Adjust to center the dot on the track */
}

input[type="range"]::-moz-range-thumb {
    transform: translateY(1px); /* Slight adjustment for Firefox */
}

/* Ensure the input value doesn't overlap with the spinners */
.price-input {
    padding-right: 106px; /* Increased to accommodate spinners + Auto toggle */
}

/* Price input container with auto toggle */
.price-container {
    position: relative;
    display: flex;
    align-items: center;
}

.price-input {
    width: 70px;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid var(--tg-theme-hint-color);
    border-radius: 8px;
    font-size: 16px;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    text-align: right;
}

/* Hide default spinners in Firefox */
.price-input {
    -moz-appearance: textfield;
}

/* Hide default spinners in Chrome, Safari, Edge */
.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Auto toggle container */
.auto-list-container {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    color: var(--tg-theme-text-color);
    font-size: 14px;
}

/* Make sure input is not covered by toggle switch */
.price-input {
    width: 100px; /* Increased width for better visibility */
    padding-right: 8px;
}

/* Add to your existing CSS */
.stats-badge {
    position: relative;
}

.tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--tg-theme-bg-color);
    border: 1px solid var(--tg-theme-hint-color);
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    color: var(--tg-theme-text-color);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    pointer-events: none;
    max-width: 90vw;
    text-overflow: ellipsis;
    overflow: hidden;
}

.stats-badge.tooltip-active .tooltip-content {
    opacity: 1;
    visibility: visible;
}

/* Special positioning for edge badges */
.stats-badge:first-child .tooltip-content {
    left: 0;
    transform: none;
}

.stats-badge:last-child .tooltip-content {
    left: auto;
    right: 0;
    transform: none;
}

/* Welcome banner styling */
.welcome-banner {
    background: var(--tg-theme-secondary-bg-color);
    padding: 4px;
    text-align: center;
    margin: 0 6px;  /* Remove top margin, keep horizontal margins */
    border-radius: 10px;
}

.welcome-banner p {
    margin: 0;
    color: var(--tg-theme-text-color);
    font-size: 14px;
}

.bot-link {
    background: none;
    border: none;
    color: var(--tg-theme-button-color);
    font-weight: 500;
    padding: 0;
    cursor: pointer;
    font-size: inherit;
}

.bot-link:hover {
    text-decoration: underline;
}

/* Update all content below nav */
.content > *:not(.top-nav) {
    margin-top: 2px;
}

/* Fix spacing for collection filter */
.collection-filter {
    margin: 8px 16px !important;
    width: calc(100% - 32px) !important;
}

/* Fix styling for collection list items in filter */
.collection-filter .collection-item {
    box-sizing: border-box;
}

/* Fix z-index for collection filter elements */
.collection-filter-header {
    z-index: 5;
}

/* Fix collection filter styling */
.collection-filter .collection-preview {
    width: 36px !important;
    height: 36px !important;
}