/* =============================================================================
   POK Payments — form styles
   Brand primary: #04557C. Override the custom properties on
   #pok-payment-container in your own stylesheet to retheme without forking.
   Class names and keyframe names are part of the public override surface and
   must not be renamed.
   ============================================================================= */

#pok-payment-container {
    /* Brand */
    --pok-primary: #04557c;
    --pok-primary-hover: #0a6d9c;
    --pok-primary-active: #033f5c;
    --pok-primary-tint: rgba(4, 85, 124, 0.06);
    --pok-primary-tint-strong: rgba(4, 85, 124, 0.14);
    --pok-primary-ring: rgba(4, 85, 124, 0.18);

    /* Surfaces & text (tinted toward primary, never pure black) */
    --pok-surface: #ffffff;
    --pok-surface-soft: #f5f7fa;
    --pok-text: #0e1e2c;
    --pok-text-muted: #4d5d70;
    --pok-text-subtle: #8492a4;

    /* Lines */
    --pok-border: #d8e0eb;
    --pok-border-strong: #b1bccc;

    /* Status */
    --pok-error: #bd2f43;
    --pok-error-tint: rgba(189, 47, 67, 0.08);
    --pok-error-ring: rgba(189, 47, 67, 0.18);
    --pok-success: #1a7a5a;

    /* Shape */
    --pok-radius: 10px;
    --pok-radius-sm: 6px;
    --pok-radius-pill: 999px;

    /* Elevation */
    --pok-shadow-input: 0 1px 0 rgba(15, 23, 42, 0.02);
    --pok-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04),
                       0 4px 16px rgba(15, 23, 42, 0.06);
    --pok-shadow-popover: 0 1px 2px rgba(15, 23, 42, 0.06),
                          0 12px 32px -8px rgba(15, 23, 42, 0.18);

    /* Motion */
    --pok-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --pok-dur: 220ms;

    /* Type — system fonts only; an embedded form should match the host UI */
    --pok-font: -apple-system, BlinkMacSystemFont, "SF Pro Text",
                "Segoe UI Variable", "Segoe UI", "Helvetica Neue",
                system-ui, Roboto, Ubuntu, sans-serif,
                "Apple Color Emoji", "Segoe UI Emoji";

    position: relative;
    min-height: 350px;
    color: var(--pok-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

#pok-payment-container * {
    font-family: var(--pok-font);
    box-sizing: border-box;
}

#pok-payment-container ::selection {
    background: var(--pok-primary-tint-strong);
    color: var(--pok-text);
}

/* ---------- Loading overlay -------------------------------------------------- */

.pok-payment-loading-screen {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: saturate(140%) blur(2px);
    -webkit-backdrop-filter: saturate(140%) blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeInUp 200ms var(--pok-ease) both;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Form shell ------------------------------------------------------- */

.pok-payment-form {
    background: var(--pok-surface);
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 24px;
    border: 1px solid var(--pok-border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    animation: slideInFromBottom 360ms var(--pok-ease) both;
}

@keyframes slideInFromBottom {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pok-payment-input-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.875rem;
}

/* ---------- Inputs --------------------------------------------------------- */

/* Each field is rendered inside a .pok-payment-relative wrapper that holds:
       <label>          → above the input
       <input>          → 44px tall, rounded
       optional .pok-payment-input-icon  (CInput appendIcon)
       optional .pok-payment-clear       (CSelect chevron / clear)
   The trailing-icon classes are absolutely positioned to align with the
   input box only — never the label. */

.pok-payment-relative {
    position: relative;
}

.pok-payment-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--pok-text-muted);
    letter-spacing: 0;
    text-transform: none;
    padding: 0;
    transition: color var(--pok-dur) var(--pok-ease);
}

.pok-payment-input {
    display: block;
    width: 100%;
    height: 2.5rem;
    padding: 0 0.75rem;
    background: var(--pok-surface);
    color: var(--pok-text);
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: 0;
    border: 1px solid var(--pok-border);
    border-radius: var(--pok-radius);
    outline: none;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
    font-variant-numeric: tabular-nums;
    transition: border-color 160ms var(--pok-ease),
                box-shadow 160ms var(--pok-ease);
}

.pok-payment-input::placeholder {
    color: var(--pok-text-subtle);
    font-weight: 400;
}

/* Mobile Safari zooms inputs on focus when their computed font-size is below
   16px. Pin to 16px under the mobile breakpoint so the form doesn't jump. */
@media (max-width: 480px) {
    .pok-payment-input {
        font-size: 16px;
    }
}

.pok-payment-input:hover:not(:focus):not(.pok-payment-input-disabled) {
    border-color: var(--pok-border-strong);
}

.pok-payment-input:focus {
    border-color: var(--pok-primary);
    box-shadow: 0 0 0 3px var(--pok-primary-ring);
}

.pok-payment-input-error {
    border-color: var(--pok-error);
}

.pok-payment-input-error:focus {
    border-color: var(--pok-error);
    box-shadow: 0 0 0 3px var(--pok-error-ring);
}

.pok-payment-label-error {
    color: var(--pok-error);
}

.pok-payment-input-disabled,
.pok-payment-input:disabled {
    background-color: var(--pok-surface-soft);
    color: var(--pok-text-muted);
    cursor: not-allowed;
    border-color: var(--pok-border);
}

/* Wrapper around <input> + trailing icons + popover.
   Sized to the input only — never the label or error text — so absolutely
   positioned children (chevron, options popover) don't drift when validation
   adds a sibling error message into .pok-payment-relative. */
.pok-payment-input-wrap {
    position: relative;
}

/* Trailing icon area — aligns to the input box, not the wrapper.
   Used by CInput appendIcon (.pok-payment-input-icon) and
   CSelect chevron/clear (.pok-payment-clear). */
.pok-payment-input-icon,
.pok-payment-clear {
    position: absolute;
    top: 1px;
    bottom: 1px;
    right: 1px;
    width: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pok-text-subtle);
    line-height: 0;
    pointer-events: none;
    transition: color 160ms var(--pok-ease);
}

.pok-payment-clear {
    cursor: pointer;
    pointer-events: auto;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    appearance: none;
    -webkit-appearance: none;
}

.pok-payment-clear:hover {
    color: var(--pok-text);
}

.pok-payment-clear:focus-visible {
    outline: 2px solid var(--pok-primary);
    outline-offset: 2px;
    border-radius: var(--pok-radius-sm);
}

.pok-payment-clear:disabled {
    cursor: not-allowed;
    color: var(--pok-text-subtle);
}

/* Reserve right padding inside the input only when an icon is present. */
.pok-payment-input-wrap:has(> .pok-payment-input-icon) > .pok-payment-input,
.pok-payment-input-wrap:has(> .pok-payment-clear) > .pok-payment-input {
    padding-right: 2.5rem;
}

/* Per-field error text — sibling of .pok-payment-input-wrap, below it. */
.pok-payment-error-text {
    margin: 0.25rem 0 0;
    font-size: 0.625rem;
    font-weight: 400;
    line-height: 1.3;
    color: var(--pok-error);
    letter-spacing: 0;
}

/* ---------- Checkbox -------------------------------------------------------- */

.pok-payment-checkbox-container {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.125rem 0;
}

.pok-payment-checkbox-container input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--pok-border-strong);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    background: var(--pok-surface);
    flex-shrink: 0;
    transition: border-color 180ms var(--pok-ease),
                background-color 180ms var(--pok-ease),
                box-shadow 180ms var(--pok-ease);
}

.pok-payment-checkbox-container input[type="checkbox"]:hover:not(:disabled) {
    border-color: var(--pok-primary);
}

.pok-payment-checkbox-container input[type="checkbox"]:focus-visible {
    outline: none;
    border-color: var(--pok-primary);
    box-shadow: 0 0 0 4px var(--pok-primary-ring);
}

.pok-payment-checkbox-container input[type="checkbox"]:checked {
    border-color: var(--pok-primary);
    background-color: var(--pok-primary);
}

.pok-payment-checkbox-container input[type="checkbox"]:disabled {
    background-color: var(--pok-surface-soft);
    border-color: var(--pok-border);
    cursor: not-allowed;
    opacity: 0.6;
}

.pok-payment-checkbox-container input[type="checkbox"]::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: translate(-50%, -68%) rotate(-45deg) scale(0.6);
    opacity: 0;
    transition: transform 160ms var(--pok-ease),
                opacity 160ms var(--pok-ease);
}

.pok-payment-checkbox-container input[type="checkbox"]:checked::before {
    opacity: 1;
    transform: translate(-50%, -68%) rotate(-45deg) scale(1);
}

.pok-payment-checkbox-container label {
    margin-left: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--pok-text-muted);
    cursor: pointer;
    user-select: none;
}

/* ---------- Primary button -------------------------------------------------- */

.pok-payment-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.8125rem 1.25rem;
    background: var(--pok-primary);
    color: #ffffff;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.25rem;
    letter-spacing: 0;
    border: none;
    border-radius: var(--pok-radius);
    cursor: pointer;
    box-shadow: none;
    transition: background-color 180ms var(--pok-ease),
                transform 120ms var(--pok-ease),
                box-shadow 180ms var(--pok-ease);
}

.pok-payment-button:hover {
    background: var(--pok-primary-hover);
}

.pok-payment-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--pok-primary-ring);
}

.pok-payment-button:active:not(:disabled) {
    background: var(--pok-primary-active);
    transform: translateY(1px);
}

.pok-payment-button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

/* ---------- Inline error banner --------------------------------------------- */

.pok-payment-error-message {
    background: var(--pok-error-tint);
    color: var(--pok-error);
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-left: 3px solid var(--pok-error);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    border-radius: var(--pok-radius-sm);
    transform-origin: top center;
    animation: slideInError 280ms var(--pok-ease) both;
}

/* Animates only opacity + transform — never max-height/padding (jank-free). */
@keyframes slideInError {
    from { opacity: 0; transform: translateY(-4px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Spinner --------------------------------------------------------- */

/* Default: spinner on the light loading overlay — brand-tinted arc on white. */
.pok-payment-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid var(--pok-primary-tint-strong);
    border-top-color: var(--pok-primary);
    border-radius: 50%;
    animation: spin 720ms linear infinite;
    display: inline-block;
    margin-right: 0;
}

/* On the primary button background: white arc on dark blue. */
.pok-payment-button .pok-payment-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.32);
    border-top-color: #ffffff;
}

.pok-payment-loading .button-text {
    display: none;
}

/* ---------- Success / error info screens ----------------------------------- */

.pok-payment-info-container {
    width: 100%;
    height: 100%;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
    animation: fadeInScale 420ms var(--pok-ease) both;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.97) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.pok-payment-info-icon {
    height: 4rem;
    width: 4rem;
    margin-bottom: 1rem;
    animation: bounceIn 480ms var(--pok-ease) 80ms both;
}

/* Replaced the old overshoot easing — this lands smoothly, not bouncy. */
@keyframes bounceIn {
    from { opacity: 0; transform: scale(0.86); }
    to   { opacity: 1; transform: scale(1); }
}

.pok-payment-info-title {
    font-size: 1.25rem;
    margin: 0 0 0.5rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--pok-text);
    text-align: center;
    animation: slideInFromTop 380ms var(--pok-ease) 160ms both;
}

@keyframes slideInFromTop {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pok-payment-info-message {
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--pok-text-muted);
    margin: 0;
    max-width: 28em;
    text-align: center;
    animation: fadeInUp 380ms var(--pok-ease) 240ms both;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Old constant pulse was visual noise on a payment outcome — removed.
   Keyframe kept as a no-op so external rules referencing it don't break. */
.pok-payment-info-container .pok-payment-info-icon img {
    animation: none;
}

@keyframes successPulse {
    from { transform: none; opacity: 1; }
    to   { transform: none; opacity: 1; }
}

/* ---------- Country / state select dropdown -------------------------------- */

.pok-payment-options {
    position: absolute;
    left: 0;
    width: 100%;
    max-height: 17.5rem;
    overflow-y: auto;
    background: var(--pok-surface);
    border: 1px solid var(--pok-border);
    border-radius: var(--pok-radius);
    box-shadow: var(--pok-shadow-popover);
    margin: 0;
    z-index: 10;
    padding: 0.25rem;
    overscroll-behavior: contain;
}

.pok-payment-options-down {
    top: calc(100% + 4px);
    transform-origin: top;
    animation: slideInFromTop 200ms var(--pok-ease) both;
}

.pok-payment-options-up {
    bottom: calc(100% + 4px);
    transform-origin: bottom;
    animation: slideInFromBottom 200ms var(--pok-ease) both;
}

.pok-payment-options-hidden {
    display: none;
}

.pok-payment-option {
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.35rem;
    color: var(--pok-text);
    cursor: pointer;
    border-radius: var(--pok-radius-sm);
    transition: background-color 140ms ease, color 140ms ease;
}

.pok-payment-option:hover,
.pok-payment-option-active {
    background: var(--pok-primary-tint);
}

.pok-payment-option-selected {
    background: var(--pok-primary);
    color: #ffffff;
}

.pok-payment-option-selected:hover,
.pok-payment-option-selected.pok-payment-option-active {
    background: var(--pok-primary-hover);
    color: #ffffff;
}

.pok-payment-option-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.pok-payment-option-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pok-payment-option-empty {
    padding: 0.75rem;
    font-size: 0.8125rem;
    color: var(--pok-text-muted);
    text-align: center;
}

.pok-payment-flag {
    display: block;
    flex-shrink: 0;
    border-radius: 50%;
    user-select: none;
}

.pok-payment-options::-webkit-scrollbar { width: 8px; }
.pok-payment-options::-webkit-scrollbar-thumb {
    background: var(--pok-border-strong);
    border-radius: 8px;
    border: 2px solid var(--pok-surface);
}
.pok-payment-options::-webkit-scrollbar-track { background: transparent; }

/* ---------- Country modal variant ------------------------------------------ */

/* The trigger looks like the dropdown input, but it's a real <button> so we
   reset its native styling and align text to the left. */
.pok-payment-modal-trigger {
    text-align: left;
    cursor: pointer;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--pok-text);
    background: var(--pok-surface);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pok-payment-modal-trigger-empty {
    color: var(--pok-text-subtle);
    font-weight: 400;
}

.pok-payment-modal-trigger:disabled {
    cursor: not-allowed;
}

.pok-payment-modal-backdrop {
    /* Modal renders via React portal on document.body — outside the
       #pok-payment-container scope where these tokens are normally declared.
       Mirror the defaults here so the portal subtree resolves them. Authors
       who retheme on #pok-payment-container should also override on
       .pok-payment-modal-backdrop to recolor the modal. */
    --pok-primary: #04557c;
    --pok-primary-hover: #0a6d9c;
    --pok-primary-tint: rgba(4, 85, 124, 0.06);
    --pok-primary-ring: rgba(4, 85, 124, 0.18);
    --pok-surface: #ffffff;
    --pok-surface-soft: #f5f7fa;
    --pok-text: #0e1e2c;
    --pok-text-muted: #4d5d70;
    --pok-text-subtle: #8492a4;
    --pok-border: #d8e0eb;
    --pok-border-strong: #b1bccc;
    --pok-error: #bd2f43;
    --pok-radius: 10px;
    --pok-radius-sm: 6px;
    --pok-ease: cubic-bezier(0.16, 1, 0.3, 1);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
                 "Segoe UI Variable", "Segoe UI", "Helvetica Neue",
                 system-ui, Roboto, Ubuntu, sans-serif;

    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 160ms var(--pok-ease) both;
}

.pok-payment-modal {
    width: 100%;
    max-width: 420px;
    max-height: min(80vh, 600px);
    display: flex;
    flex-direction: column;
    background: var(--pok-surface);
    border-radius: var(--pok-radius-lg, 12px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: modalIn 200ms var(--pok-ease) both;
}

.pok-payment-modal-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--pok-border);
    flex-shrink: 0;
}

.pok-payment-modal-title-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.pok-payment-modal-search {
    flex: 1;
    min-width: 0;
    height: 2.5rem;
    padding: 0 0.75rem;
    font: inherit;
    font-size: 0.875rem;
    color: var(--pok-text);
    background: var(--pok-surface-soft, var(--pok-surface));
    border: 1px solid var(--pok-border);
    border-radius: var(--pok-radius);
    outline: none;
    transition: border-color 160ms var(--pok-ease), box-shadow 160ms var(--pok-ease);
}

.pok-payment-modal-search::placeholder {
    color: var(--pok-text-subtle);
}

.pok-payment-modal-search:focus {
    border-color: var(--pok-primary);
    box-shadow: 0 0 0 3px var(--pok-primary-ring);
}

.pok-payment-modal-close {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: var(--pok-radius);
    color: var(--pok-text-subtle);
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease;
}

.pok-payment-modal-close:hover {
    background: var(--pok-surface-soft, rgba(0, 0, 0, 0.04));
    color: var(--pok-text);
}

.pok-payment-modal-close:focus-visible {
    outline: 2px solid var(--pok-primary);
    outline-offset: 2px;
}

.pok-payment-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem;
    overscroll-behavior: contain;
}

.pok-payment-modal-body::-webkit-scrollbar { width: 8px; }
.pok-payment-modal-body::-webkit-scrollbar-thumb {
    background: var(--pok-border-strong);
    border-radius: 8px;
    border: 2px solid var(--pok-surface);
}
.pok-payment-modal-body::-webkit-scrollbar-track { background: transparent; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Full-screen sheet on small screens. */
@media (max-width: 600px) {
    .pok-payment-modal-backdrop {
        padding: 0;
        align-items: stretch;
    }
    .pok-payment-modal {
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }
    .pok-payment-modal-search {
        font-size: 16px; /* prevent iOS auto-zoom on focus */
    }
}

/* ---------- Form exit transition ------------------------------------------- */

.pok-payment-form-exit {
    animation: slideOutToTop 220ms ease-in forwards;
}

@keyframes slideOutToTop {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-6px); }
}

/* ---------- Responsive ----------------------------------------------------- */

@media (max-width: 480px) {
    .pok-payment-form {
        padding: 22px 18px;
        border-radius: 12px;
    }
    .pok-payment-input-row {
        grid-template-columns: 1fr;
    }
    .pok-payment-info-title { font-size: 1.25rem; }
}

/* ---------- Reduced motion ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    #pok-payment-container *,
    #pok-payment-container *::before,
    #pok-payment-container *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
