/**
 * Nexis Crypto Gateway — WooCommerce Blocks Checkout styles.
 *
 * Styles the custom popup-dropdown that nexis-checkout-blocks.js renders for
 * chain/token selection. Uses block-checkout's CSS variables so dropdowns
 * inherit the merchant's theme automatically (border-radius, primary color).
 */

.nexis-blocks {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 0;
}

.nexis-blocks__description {
    margin: 0 0 4px;
    font-size: 0.95em;
    color: var(--wp--preset--color--contrast-2, #555);
    line-height: 1.5;
}

.nexis-blocks__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nexis-blocks__field-label {
    font-size: 0.9em;
    font-weight: 500;
    color: var(--wp--preset--color--contrast, #1e1e1e);
}

/* ── Custom popup dropdown ──────────────────────────────────────────── */

.nexis-blocks__dropdown {
    position: relative;
}

.nexis-blocks__dropdown.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.nexis-blocks__dropdown-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 36px 10px 12px;
    border: 1px solid var(--wp--preset--color--contrast-3, #ccc);
    border-radius: 6px;
    background-color: #fff;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%23555' d='M6 9L1 4h10z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    font-size: 1em;
    line-height: 1.4;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

.nexis-blocks__dropdown-button:hover:not(:disabled) {
    border-color: var(--wp--preset--color--contrast-2, #888);
}

.nexis-blocks__dropdown.is-open .nexis-blocks__dropdown-button,
.nexis-blocks__dropdown-button:focus {
    outline: none;
    border-color: var(--wp--preset--color--primary, #007cba);
    box-shadow: 0 0 0 1px var(--wp--preset--color--primary, #007cba);
}

/* The arrow indicator. Background-image already shows a static caret; this
 * marker keeps DOM hooks for a future animated chevron without touching JS. */
.nexis-blocks__chevron {
    display: none;
}

.nexis-blocks__placeholder {
    color: var(--wp--preset--color--contrast-2, #888);
}

/* ── Popup list ──────────────────────────────────────────────────── */

.nexis-blocks__dropdown-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 100;
    margin: 0;
    padding: 4px;
    list-style: none;
    background-color: #fff;
    border: 1px solid var(--wp--preset--color--contrast-3, #ccc);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 280px;
    overflow-y: auto;
    animation: nexis-blocks-fade 0.12s ease;
}

@keyframes nexis-blocks-fade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.nexis-blocks__dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    line-height: 1.3;
    transition: background-color 0.1s ease;
}

.nexis-blocks__dropdown-item.is-hover,
.nexis-blocks__dropdown-item:hover {
    background-color: var(--wp--preset--color--base-2, #f3f4f6);
}

.nexis-blocks__dropdown-item.is-selected {
    background-color: rgba(0, 124, 186, 0.08);
    font-weight: 500;
}

.nexis-blocks__dropdown-item.is-selected.is-hover {
    background-color: rgba(0, 124, 186, 0.16);
}

/* ── Icon + label common ────────────────────────────────────────── */

.nexis-blocks__icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background-color: #f3f4f6;
}

.nexis-blocks__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Loading / error states ─────────────────────────────────────── */

.nexis-blocks--loading {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    color: var(--wp--preset--color--contrast-2, #555);
    font-size: 0.95em;
}

.nexis-blocks__spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--wp--preset--color--contrast-3, #ccc);
    border-top-color: var(--wp--preset--color--primary, #007cba);
    border-radius: 50%;
    animation: nexis-blocks-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes nexis-blocks-spin {
    to { transform: rotate(360deg); }
}

.nexis-blocks--error {
    padding: 12px 16px;
    border: 1px solid #e3a4a4;
    border-radius: 6px;
    background-color: #fbeaea;
    color: #7a1f1f;
    font-size: 0.95em;
    line-height: 1.5;
}

.nexis-blocks--error p {
    margin: 0 0 6px;
}

.nexis-blocks--error p:last-of-type {
    margin-bottom: 10px;
}

.nexis-blocks__error-detail {
    font-size: 0.85em;
    opacity: 0.85;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.nexis-blocks__retry {
    appearance: none;
    border: 1px solid #7a1f1f;
    background: transparent;
    color: #7a1f1f;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nexis-blocks__retry:hover {
    background-color: #7a1f1f;
    color: #fff;
}

/* ── Block-editor preview (admin Gutenberg) ─────────────────────── */

.nexis-blocks--editor-preview {
    padding: 12px 14px;
    border: 1px dashed var(--wp--preset--color--contrast-3, #ccc);
    border-radius: 6px;
    background-color: var(--wp--preset--color--base-2, #f6f6f6);
    color: var(--wp--preset--color--contrast-2, #555);
    font-style: italic;
    font-size: 0.95em;
}
