:root {
    --background: #1d1d20;
    --background2: #18181b;
    --main: #e4e4e6;
    --main-hover: #e4e4e6;
    --main-hover2: #8f8f8f;
    --accent: #ffc0cb;
    --danger: #c11d38;
    --danger-hover: #8a1428;
    --profit: #4CAF50;
    --warning: #ffc107;
    --accent-hover: rgb(237, 149, 162);
    --main-font: "Jost";
}

::selection {
    color: var(--background);
    background-color: var(--accent);
}

html {
    width: 100vw;
    height: 100vh;
    font-family: var(--main-font);
    background-color: var(--background);
    color: var(--main);
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
    width: 100%;
}

header {
    background-color: var(--background2);
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-direction: row;
    padding: 10px 10px 10px 20px;
}

#header-logo, .logo-link{
    display: flex;
    align-items: center;
    flex-direction: row;
    padding: 0;
    margin: 0;
    text-decoration: none;
    color: var(--main);
}

#title {
    margin-left: 5px;
}

#logo {
    width: 100px;
    transition: transform 1s ease-in-out;
    cursor: pointer;
}

#logo:hover {
    transform: rotate(360deg);
}

.container {
    text-align: center;
    padding: 30px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 0.5fr 1fr;
    justify-content: center;
    align-items: center;
    gap: 20px;
    grid-template-areas:
        "mode-buttons mode-buttons mode-buttons"
        "slider extra-fields games"
        "slider extra-fields games";
}

.mode-buttons {
    grid-area: mode-buttons;
    display: flex;
    gap: 10px;
    justify-content: center;
    font-family: inherit;
    font-size: 1.8rem;
    font-weight: bold;
    margin: 0 auto;
}

.mode-btn {
    border: 0;
    margin: 0;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s;
    background-color: transparent;
    color: var(--main);
    font-family: inherit;
    font-size: 1.8rem;
    font-weight: bold;
}

.mode-btn.active, .mode-btn.sell.active {
    color: var(--accent);
}

.mode-btn:not(.active):hover {
    color: var(--main-hover2);
}

#slider {
    grid-area: slider;
}

.slider-container {
    display: none;
    position: relative;
}

.slider-container.active {
    display: block;
}

#buyCanvas, #sellCanvas {
    display: block;
    margin: 0 auto;
    cursor: pointer;
}

.controls {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: grid; /* ← Меняем на grid */
    grid-template-columns: auto auto; /* Две колонки для input и label */
    grid-template-rows: auto auto; /* Две строки */
    gap: 10px;
    justify-items: center;
    align-items: center;
    z-index: 10;
    row-gap: 10px;
}

.value-input {
    width: 60px; /* Фиксированная ширина */
    padding: 8px 12px;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    background-color: var(--background2);
    border: none;
    border-radius: 8px;
    color: var(--main);
    font-family: inherit;
    transition: all 0.3s;
    grid-column: 1; /* Первая колонка */
    grid-row: 1; /* Первая строка */
    justify-self: end; /* Прижимаем к правому краю */
}

.value-input:focus {
    outline: none;
    caret-color: var(--accent);
}

.unit-label {
    font-size: 1.5rem;
    font-family: inherit;
    font-weight: bold;
    color: var(--main);
    grid-column: 2; /* Вторая колонка */
    grid-row: 1; /* Первая строка */
    justify-self: start; /* Прижимаем к левому краю */
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    /* Удалает стрелки в окне ввода числа */
    -webkit-appearance: none;
    margin: 0;
}

.submit-btn {
    padding: 12px 40px;
    font-size: 1.5rem;
    font-family: inherit;
    background-color: var(--accent);
    color: var(--background2);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    grid-column: 1 / 3; /* Занимает обе колонки */
    grid-row: 2; /* Вторая строка */
}

.submit-btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

#price-panel {
    grid-area: price-panel;
    width: 60%;
    background-color: var(--background2);
    border-radius: 14px;
    padding: 20px;
    margin: 0 auto;
}

.price-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-size: 1.3rem;
}

.exchange-rate,
.total-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--background);
    border-radius: 10px;
}

.rate-label,
.total-label {
    color: var(--main-hover2);
    font-weight: 500;
}

#rate-display,
#total-display {
    color: var(--main);
    font-weight: bold;
    font-size: 1.4rem;
}

#total-display-wrapper {
    color: var(--main);
    font-weight: bold;
    font-size: 1.4rem;
}

#rate-amount,
#rate-value,
#total-display {
    color: var(--accent);
}

.game-search {
    margin-bottom: 15px;
}

#games {
    grid-area: games;
    overflow: hidden; /* Предотвращаем выход карусели за пределы этого блока */
}

#gameSearch {
    width: 80%;
    padding: 12px 20px;
    font-size: 1.1rem;
    font-family: inherit;
    background-color: var(--background2);
    color: var(--main);
    border: 2px solid transparent;
    border-radius: 10px;
    transition: all 0.3s;
}

#gameSearch:focus {
    outline: none;
    border-color: var(--accent);
    background-color: var(--background2);
    caret-color: var(--accent);
}

#gameSearch::placeholder {
    color: var(--main-hover2);
}

.game-selector {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between; /* Разносим стрелки по краям */
    gap: 10px;
    width: 100%;
    max-width: 550px; /* Увеличиваем, чтобы вместить стрелки и карусель */
    margin: 0 auto; /* Центрируем сам селектор */
    box-sizing: border-box;
}

.arrow-btn {
    background-color: var(--background2);
    color: var(--main);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
}

.arrow-btn:hover {
    background-color: var(--accent);
    color: var(--background2);
    transform: scale(1.1);
}

.arrow-btn:active {
    transform: scale(0.95);
}

.game-display {
    width: 450px; /* Фиксированная ширина для трех элементов */
    height: 300px;
    overflow: visible; /* Снова делаем видимым */
    position: relative;
}

.game-carousel {
    display: flex;
    flex-direction: row;
    transition: transform 0.3s ease;
    cursor: grab;
}

.game-carousel:active {
    cursor: grabbing;
}

.game-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0; /* Убираем боковые отступы */
    opacity: 0.4;
    transform: scale(0.85);
    transition: all 0.4s ease;
    width: 250px; /* Ширина элемента равна ширине контейнера */
    height: 300px;
    justify-content: center;
    flex-shrink: 0;
    user-select: none; /* Запрещает выделение всего блока */
}

.game-item.active {
    opacity: 1;
    transform: scale(1);
}

.game-item.hidden {
    display: none;
}

.game-logo {
    width: 180px;
    height: 180px;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 10px;
    user-select: none; /* Запрещает выделение */
    -webkit-user-drag: none; /* Запрещает перетаскивание в webkit браузерах */
    pointer-events: none; /* Отключает события мыши на изображении */
}

.game-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
    margin: 0;
    user-select: none; /* Запрещает выделение текста */
}

.loading-message {
    text-align: center;
    color: var(--main-hover2);
    padding: 50px;
    font-size: 1.1rem;
}

.delivery-terms-btn {
    margin: 15px auto;
    padding: 12px 24px;
    background-color: var(--accent);
    border: none;
    color: var(--background2);
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.4rem;
    font-family: inherit;
    font-weight: bold;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 250px;
}

.delivery-terms-btn:hover {
    background-color: var(--accent-hover);
    color: var(--background2);
}

.delivery-terms-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.delivery-terms-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
}

.delivery-terms-content {
    position: relative;
    background-color: var(--background2);
    border-radius: 16px;
    padding: 30px;
    max-width: 600px;
    max-height: 70vh;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 1;
}

.delivery-terms-content h3 {
    margin: 0;
    color: var(--accent);
    font-size: 1.6rem;
}

.delivery-terms-text {
    overflow-y: auto;
    max-height: 45vh;
    color: var(--main);
    line-height: 1.5;
    text-align: left;
    scrollbar-width: thin;
    padding-right: 6px;
}

/* === СКРОЛЛБАР === */

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--background2);
    border-radius: 10px;
}

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

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

/* === СКРОЛЛБАР В МОДАЛЬНОМ ОКНЕ УСЛОВИЙ ДОСТАВКИ === */

.delivery-terms-text {
    scrollbar-color: var(--accent) var(--background);
}

.delivery-terms-text::-webkit-scrollbar {
    width: 10px;
}

.delivery-terms-text::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 10px;
}

.delivery-terms-text::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.delivery-terms-text::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

.delivery-terms-text p {
    margin: 0 0 12px;
    font-size: 1.05rem;
}

.delivery-terms-text ul {
    margin: 0 0 12px 18px;
    padding: 0;
    list-style: disc;
    display: grid;
    gap: 6px;
}

.delivery-terms-text li {
    padding-left: 4px;
}

.delivery-terms-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--main);
    font-size: 1.4rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.delivery-terms-close:hover {
    color: var(--accent);
}

body.delivery-terms-open {
    overflow: hidden;
}

#extra-fields {
    grid-area: extra-fields;
    background-color: var(--background2);
    border-radius: 14px;
    padding: 20px;
    display: block;
    min-height: 150px;
}

.fields-title {
    color: var(--accent);
    text-align: center;
    font-size: 1.3rem;
}

.no-fields-message {
    text-align: center;
    color: var(--main-hover2);
    padding: 20px;
    font-size: 1rem;
}

#customFieldsContainer {
    max-width: 600px;
    margin: 0 auto;
    text-align: center; /* Центрирует всё содержимое */
}

.custom-field {
    margin-bottom: 25px;
}

.custom-field label {
    display: block;
    margin-bottom: 5px;
    color: var(--main);
    font-size: 1rem;
    font-weight: 500;
}

.custom-field input,
.custom-field textarea {
    width: 80%;
    padding: 12px;
    background-color: var(--background);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--main);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s;
}

.custom-field input:focus,
.custom-field textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.custom-field textarea {
    min-height: 100px;
    resize: vertical;
}

footer {
    width: min(70%, 100%);
    margin-top: auto;
    margin-inline: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

#header-links {
    display: flex;
    justify-content: center;
    align-items: center;
}

.links {
    text-decoration: none;
    padding: 8px 10px 10px 10px;
    margin: 5px;
    color: var(--main);
    border-radius: 10px;
}

.links:hover {
    color: var(--background2);
    background-color: var(--accent);
}

#profileIcon {
    position: relative;
}

.profile-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background-color: var(--background2);
    border-radius: 10px;
    border: 2px solid var(--accent);
    padding: 15px;
    min-width: 200px;
    z-index: 1000;
}

.profile-menu a {
    display: block;
    padding: 10px;
    color: var(--main);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s;
}

.profile-menu a:hover {
    background-color: var(--accent);
    color: var(--background2);
}

.profile-email {
    color: var(--accent);
    font-weight: bold;
    padding: 10px;
    border-bottom: 2px solid var(--background);
    margin-bottom: 10px;
}

.footer-links {
    text-decoration: none;
    padding: 8px 10px 10px 10px;
    margin: 5px;
    color: var(--main);
    border-radius: 10px;
}

.footer-links:hover {
    color: var(--accent);
}

.custom-select-wrapper {
    position: relative;
    width: 90%;
    margin: 0 auto;
}

.custom-select-styled {
    position: relative;
    padding: 12px;
    background-color: var(--background); /* ✅ Такой же фон как у input */
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--main);
    cursor: pointer;
    user-select: none;
    transition: all 0.3s;
    text-align: left; /* ✅ Текст слева */
    font-family: inherit;
    font-size: 1rem;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23ffc0cb' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.custom-select-styled:hover,
.custom-select-styled.active {
    border-color: var(--accent);
    background-color: var(--background);
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 999;
    margin: 5px 0 0 0;
    padding: 0;
    list-style: none;
    background-color: var(--background2);
    border: 2px solid var(--accent);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.custom-select-options li {
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--main);
    text-align: left; /* ✅ Текст слева в списке */
}

.custom-select-options li:hover {
    background-color: var(--accent); /* ✅ Розовый при наведении */
    color: var(--background2);
}

/* ✅ Скрываем оригинальные select до инициализации кастомных */
.custom-select:not([data-customized]) {
    opacity: 0;
}

/* После инициализации показываем (уже будут скрыты через display: none в JS) */
.custom-select[data-customized] {
    display: none !important;
}

.info-notice {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 12px 20px;
    background-color: rgba(255, 192, 203, 0.1);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    color: var(--main);
    font-size: 0.95rem;
    text-align: center;
}

/* === БЕЙДЖ УВЕДОМЛЕНИЙ === */
.badge {
    display: inline-block;
    background-color: #ff4444;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-left: 8px;
    min-width: 20px;
    text-align: center;
}

/* === ПОИСК ЗАКАЗОВ === */

.orders-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
}

.orders-header h2 {
    margin: 0;
}

.search-input {
    flex: 1;
    max-width: 400px;
    padding: 12px 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    background-color: var(--background);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.order-id-label {
    font-size: 1rem;
    color: var(--main);
    font-weight: bold;
}

.order-id-number {
    color: var(--accent);
    margin-right: 10px;
}

/* Новые статусы */
.order-status.unpaid {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    background-color: var(--danger);
    color: white;
}

.order-status.paid {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    background-color: var(--profit);
    color: white;
}

.order-status.processing {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    background-color: var(--warning);
    color: var(--background2);
}

@media (max-width: 768px) {
    .orders-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-input {
        max-width: 100%;
    }
}