/* ==========================================================================
   components.css — переиспользуемые UI-компоненты:
   поля ввода, чекбоксы, селекты валют/сетей, dropdown, модалки,
   аккордеон, бейджи, уведомления
   ========================================================================== */

/* ---------- Form field ---------- */
.form-field {
    min-width: 0;
    line-height: 1.4;
}

.form-field__label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-muted);
}

.input {
    display: block;
    width: 100%;
    height: 48px;
    padding: 0 12px 0 16px;
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 16px;
    font-weight: 500;
    color: var(--color-heading);
    outline: none;
    transition: border-color 0.1s ease;
    -webkit-appearance: none;
    appearance: none;
}

.input::placeholder {
    color: var(--color-placeholder);
    opacity: 1;
}

.input:focus-visible {
    border-color: rgba(255, 255, 255, 0.2);
    outline: none;
}

.input.is-invalid,
.is-invalid > .input {
    border-color: #e03131 !important;
}

.form-field__hint {
    display: block;
    margin: 8px 0 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-muted);
}

.form-field__hint em {
    font-style: normal;
    color: var(--color-primary);
}

.form-field__error {
    display: block;
    margin: 6px 0 0;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-danger);
}

/* ---------- Password field ---------- */
.password-field {
    position: relative;
}

.password-field .input {
    height: 50px;
    padding-right: 48px;
}

.password-field__toggle {
    position: absolute;
    top: 1px;
    right: 9px;
    bottom: 1px;
    width: 32px;
    height: 32px;
    margin: auto 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #dee2e6;
    cursor: pointer;
}

.password-field__toggle:hover {
    background: rgba(134, 142, 150, 0.2);
}

.password-field__toggle svg {
    display: block;
    width: 19px;
    height: 19px;
}

/* ---------- Checkbox ---------- */
.checkbox {
    display: flex;
    align-items: flex-start;
    font-size: 14px;
    line-height: 16px;
    cursor: pointer;
}

.checkbox__control {
    position: relative;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.checkbox__input {
    display: block;
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    border: 1px solid #424242;
    border-radius: var(--radius-sm);
    background-color: var(--color-disabled-bg);
    cursor: pointer;
    transition: border-color 0.1s ease, background-color 0.1s ease;
    -webkit-appearance: none;
    appearance: none;
}

.checkbox__input:checked {
    border-color: var(--color-primary);
    background-color: var(--color-primary);
}

.checkbox__icon {
    position: absolute;
    inset: 0;
    width: 60%;
    margin: auto;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transform: translateY(5px) scale(0.5);
    transition: transform 0.1s ease, opacity 0.1s ease;
}

.checkbox__input:checked + .checkbox__icon {
    opacity: 1;
    transform: none;
}

.checkbox__label {
    padding-left: 12px;
}

.checkbox.is-invalid .checkbox__input {
    border-color: #e03131;
}

/* Вариант для модалок авторизации */
.checkbox--compact {
    color: var(--color-muted);
}

.checkbox--compact .checkbox__input {
    border-radius: 2px;
    background-color: transparent;
}

.checkbox--compact .checkbox__input:checked {
    background-color: var(--color-primary);
}

.checkbox--compact .checkbox__label {
    padding-left: 8px;
    font-weight: 400;
    line-height: 1.3;
    user-select: none;
}

.checkbox--compact .checkbox__label a {
    text-underline-offset: 1px;
}

/* ---------- Amount group: сумма + выбор валюты ---------- */
.amount-group {
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.amount-group:focus-within {
    border-color: rgba(87, 108, 211, 0.4);
    box-shadow: 0 0 0 3px rgba(87, 108, 211, 0.12);
}

.amount-group__input {
    flex-grow: 1;
    min-width: 0;
    height: 52px;
    padding: 0 16px;
    border: 0;
    border-radius: 0;
    background-color: transparent;
    font-size: 16px;
    font-weight: 500;
    color: var(--color-heading);
    outline: none;
}

.amount-group__input::placeholder {
    color: var(--color-placeholder);
}

/* Знак «≈» у рассчитанной суммы */
.amount-group__input--approx {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M18.9 9.2c-.8.9-2.3 1.8-3.9 1.8c-1.5 0-2.4-.5-3.2-.9c-.8-.3-1.6-.8-2.9-.8c-1.2 0-2.3.7-2.9 1.3L5 9.1c.9-.9 2.3-1.9 3.9-1.9c1.5 0 2.4.6 3.2.9s1.6.9 2.9.9c1.2 0 2.3-.8 2.9-1.4zm.1 4.9c-.9.9-2.3 1.9-3.9 1.9c-1.5 0-2.4-.5-3.2-.9c-.8-.3-1.6-.9-2.9-.9c-1.2 0-2.3.8-2.9 1.4l-1-1.6c.9-.9 2.3-1.9 3.9-1.9c1.5 0 2.4.5 3.2.9c.8.3 1.6.8 2.9.8c1.2 0 2.3-.8 2.9-1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 24px;
    background-position: calc(100% - 10px) 50%;
}

.amount-group__select {
    flex-shrink: 0;
    width: 140px;
    background-color: rgba(255, 255, 255, 0.05);
}

.amount-group.is-invalid {
    border-color: rgba(240, 68, 56, 0.6);
}

/* Вариант для страницы обмена */
.amount-group--page {
    height: 64px;
    overflow: visible;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-weight: 500;
    color: var(--color-heading);
}

.amount-group--page:focus-within {
    border-color: var(--color-border);
    box-shadow: none;
}

.amount-group--page .amount-group__input {
    height: 100%;
    padding: 0 24px;
    border-radius: 8px 0 0 8px;
    font-size: 18px;
    font-weight: 500;
}

.amount-group--page .amount-group__input:focus {
    background-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.amount-group--page .amount-group__select {
    width: auto;
    border-radius: 0 8px 8px 0;
    background: var(--color-border);
}

/* ---------- Currency select (кнопка) ---------- */
.currency-select {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-heading);
    cursor: pointer;
    outline-offset: -2px;
}

.currency-select__value {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 0 36px 0 12px;
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
    color: var(--color-heading);
}

.currency-select__icon {
    display: block;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.currency-select__chevron {
    position: absolute;
    top: calc(50% - 14px);
    right: 6px;
    width: 28px;
    height: 28px;
    color: var(--color-placeholder);
    pointer-events: none;
}

/* ---------- Network select (кнопка) ---------- */
.network-select {
    position: relative;
    width: 100%;
}

.network-select.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.network-select__button {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 48px;
    padding: 0 40px 0 16px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: transparent;
    font-size: 16px;
    font-weight: 500;
    color: var(--color-heading);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.network-select.is-open .network-select__button {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.network-select__value {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.network-select__icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: contain;
}

.network-select__text {
    flex: 1 1 auto;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.network-select__chevron {
    position: absolute;
    top: calc(50% - 10px);
    right: 12px;
    width: 20px;
    height: 20px;
    color: var(--color-muted);
    pointer-events: none;
    transition: transform 0.12s ease;
}

.network-select.is-open .network-select__chevron {
    transform: rotate(180deg);
}

/* ---------- Select dropdown (общий для валют и сетей) ---------- */
.select-dropdown {
    position: absolute;
    z-index: 300;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #424242;
    border-radius: var(--radius-sm);
    background-color: var(--color-dropdown);
    font-size: 16px;
    line-height: 1.4;
}

.select-dropdown--currency {
    width: 300px;
}

.select-dropdown--network {
    border-color: var(--color-border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.select-dropdown__search {
    flex-shrink: 0;
    padding: 0 16px;
    background: url("data:image/svg+xml,%3Csvg width='24' height='24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m19.8 19.8-4.034-4.034M4.2 10.924a6.724 6.724 0 1 1 13.448 0 6.724 6.724 0 0 1-13.448 0Z' stroke='%23576CD3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat 16px 50% / 24px;
}

.select-dropdown__search-input {
    display: block;
    width: 100%;
    height: 50px;
    margin: 5px 0;
    padding: 0 0 0 32px;
    border: 0;
    border-bottom: 1px solid #3a3f47;
    border-radius: 0;
    background: none;
    font-size: 16px;
    color: var(--color-gray);
    outline: none !important;
}

.select-dropdown__search-input:focus {
    border-bottom-color: #505762;
}

.select-dropdown__search-input::placeholder {
    color: var(--color-placeholder);
}

.select-dropdown__list {
    max-height: 300px;
    padding: 0 10px 4px 4px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #4b4b55 transparent;
}

.select-dropdown--network .select-dropdown__list {
    max-height: 260px;
}

.select-dropdown__empty {
    padding: 16px;
    font-size: 14px;
    color: var(--color-gray);
}

/* Опция валюты */
.currency-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    border: 0;
    border-radius: var(--radius-sm);
    background-color: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.currency-option:hover,
.currency-option.is-active {
    background-color: rgba(255, 255, 255, 0.05);
}

.currency-option[aria-selected='true'] {
    background: rgba(255, 255, 255, 0.1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E") no-repeat calc(100% - 10px) 50% / 20px;
}

.currency-option__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
}

.currency-option__content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1;
    gap: 2px;
}

.currency-option__code {
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
    color: var(--color-heading);
}

.currency-option__name {
    font-size: 14px;
    line-height: 1;
    color: var(--color-gray);
}

/* Опция сети */
.network-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 18px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.network-option:hover,
.network-option.is-active {
    background: rgba(87, 108, 211, 0.18);
}

.network-option[aria-selected='true'] {
    background: rgba(87, 108, 211, 0.24);
}

.network-option__icon {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: contain;
}

.network-option__text {
    flex: 1 1 auto;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-heading);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.network-option__check {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-left: auto;
    color: var(--color-primary);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.network-option[aria-selected='true'] .network-option__check {
    opacity: 1;
    transform: scale(1);
}

/* ---------- Swap button ---------- */
.swap-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.swap-btn:active {
    transform: rotate(180deg);
}

.swap-btn img {
    display: block;
}

/* ---------- Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
}

.modal__overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal__inner {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5dvh 5vw;
    pointer-events: none;
}

.modal__content {
    flex: 0 0 560px;
    max-width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    border-radius: 24px;
    background-color: var(--color-modal);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    pointer-events: all;
    transform: translateY(-20px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal__content:focus,
.drawer__panel:focus {
    outline: none;
}

.modal.is-open .modal__overlay {
    opacity: 1;
}

.modal.is-open .modal__content {
    opacity: 1;
    transform: none;
}

.modal__header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    margin: 32px 32px 24px;
    padding: 0 0 24px;
    border-bottom: 1px solid #2c2c37;
    background-color: var(--color-modal);
}

.modal__title {
    width: 100%;
    margin: 0;
    padding: 0;
    font-size: 24px;
    font-weight: 500;
    line-height: 1;
    color: var(--color-heading);
}

.modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #b8b8b8;
    cursor: pointer;
}

.modal__close:hover {
    background-color: var(--color-disabled-bg);
}

.modal__close svg {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
}

.modal__body {
    padding: 0 32px 32px;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--color-muted);
}

/* ---------- Auth forms ---------- */
.auth-form {
    display: flex;
    flex-direction: column;
}

.auth-form .form-field {
    margin-bottom: 16px;
}

.auth-form .form-field__label {
    line-height: 1.2;
}

.auth-form__text {
    margin: 0 0 24px;
    color: var(--color-dimmed);
}

.auth-form__password-help {
    display: block;
    width: 100%;
    margin: -11px 0 16px;
    font-size: 11px;
    font-weight: 300;
    line-height: 1.2;
}

.auth-form__remember {
    min-height: 18px;
}

.auth-form__agreement {
    min-height: 25px;
}

.auth-form__submit {
    margin-top: 24px;
}

.auth-form__links {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
}

.auth-form__links--center {
    justify-content: center;
}

.auth-form--forgot .auth-form__links {
    margin-top: 40px;
}

.auth-form--forgot .auth-form__submit {
    margin-top: 56px;
}

.auth-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 400;
    color: var(--color-gray);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.auth-link svg {
    flex-shrink: 0;
}

.auth-form__message {
    margin: 16px 0 0;
    font-size: 14px;
    text-align: center;
}

.auth-form__message.is-error {
    color: var(--color-danger);
}

.auth-form__message.is-success {
    color: #12b76a;
}

/* ---------- Pills / chips ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 8px;
    padding: 6px 18px;
    border-radius: 999px;
    background: rgba(87, 105, 234, 0.12);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--color-primary);
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(87, 105, 234, 0.14);
    font-size: 15px;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.chip:hover {
    color: var(--color-primary);
    text-decoration: none;
    background: rgba(87, 105, 234, 0.22);
    transform: translateY(-2px);
}

/* ---------- Accordion (FAQ) ---------- */
.accordion__item {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.accordion__item + .accordion__item {
    margin-top: 12px;
}

.accordion__control {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    width: 100%;
    padding: 18px 22px;
    border: 0;
    background: transparent;
    font-size: 17px;
    line-height: 1.2;
    color: var(--color-heading);
    text-align: left;
    cursor: pointer;
}

.accordion__label {
    flex: 1;
    overflow: hidden;
    padding: 12px 0;
    font-weight: 400;
    text-overflow: ellipsis;
}

.accordion__chevron {
    display: flex;
    align-items: center;
    width: 15px;
    min-width: 15px;
    color: var(--color-primary);
    transition: transform 0.2s ease;
}

.accordion__chevron svg {
    display: block;
    width: 16px;
    height: 16px;
}

.accordion__item.is-open .accordion__chevron {
    transform: rotate(180deg);
}

.accordion__panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.2s ease;
}

.accordion__item.is-open .accordion__panel {
    grid-template-rows: 1fr;
}

.accordion__panel-inner {
    min-height: 0;
    overflow: hidden;
}

.accordion__content {
    padding: 5px 38px 34px;
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-gray);
    word-break: break-word;
}

.accordion__content p {
    margin: 16px 0 12px;
}

.accordion__content a {
    color: var(--color-primary);
}

/* Простой аккордеон без карточек (реферальная программа) */
.accordion--plain .accordion__item {
    border: 0;
    border-radius: 0;
    background: none;
}

.accordion--plain .accordion__item + .accordion__item {
    margin-top: 24px;
}

.accordion--plain .accordion__control {
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    min-height: 25px;
    padding: 0;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
}

.accordion--plain .accordion__label {
    flex: 0 1 auto;
    padding: 0;
    font-weight: 500;
}

.accordion--plain .accordion__chevron {
    width: 16px;
    min-width: 16px;
    transform: rotate(-90deg);
    transition: transform 0.3s ease;
}

.accordion--plain .accordion__item.is-open .accordion__chevron {
    transform: none;
}

.accordion--plain .accordion__content {
    padding: 12px 0 0 26px;
    font-size: 16px;
    line-height: 1.4;
    color: var(--color-muted);
}

.accordion--plain .accordion__content p {
    margin: 0 0 8px;
}

/* ---------- Toast notifications ---------- */
.toasts {
    position: fixed;
    top: 16px;
    left: 50%;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 300px;
    max-width: calc(100vw - 32px);
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    position: relative;
    padding: 12px 16px 12px 22px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-modal);
    box-shadow: var(--shadow-xl);
    font-size: 14px;
    line-height: 1.4;
    color: var(--color-muted);
    pointer-events: all;
    animation: fade-in-up 0.2s ease-out;
}

.toast::before {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 8px;
    width: 4px;
    border-radius: 4px;
    background: var(--color-primary);
}

.toast--error::before {
    background: var(--color-danger);
}

.toast--success::before {
    background: #12b76a;
}

.toast__title {
    margin-bottom: 2px;
    font-size: 15px;
    font-weight: 500;
    color: var(--color-heading);
}
