/*
 * Shared storefront credit-card input.
 *
 * Used by every payment plugin that still collects raw card data on our own page
 * (Manual, AuthorizeNet, AkbankPos, GarantiPos, ParamPos, Iyzico, PayTR, Tranzila).
 * The markup contract and the behaviour live in wwwroot/js/opus-credit-card.js.
 *
 * Plain CSS on purpose: opus-theme.css is a generated Tailwind bundle and is
 * gitignored, so component styles that must survive without a css build live here
 * and are linked from Views/Shared/Head.cshtml. All colours resolve through the
 * --opus-* token layer, so tenant theme overrides repaint this too.
 */

.opus-cc {
    display: grid;
    gap: var(--opus-spacing-6, 24px);
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

@media (min-width: 768px) {
    .opus-cc.opus-cc--with-preview {
        grid-template-columns: 300px minmax(0, 1fr);
        gap: var(--opus-spacing-8, 32px);
    }
}

/* ── Card preview ───────────────────────────────────────────────────────── */

.opus-cc-preview {
    perspective: 1200px;
    width: 100%;
    max-width: 340px;
    aspect-ratio: 1.586;
    user-select: none;
}

.opus-cc-preview-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform .55s cubic-bezier(.4, .2, .2, 1);
}

.opus-cc[data-cc-face="back"] .opus-cc-preview-inner {
    transform: rotateY(180deg);
}

.opus-cc-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--opus-radius-lg, 12px);
    background: linear-gradient(135deg, var(--opus-color-primary, #00237C) 0%, var(--opus-color-secondary, #1E293B) 100%);
    color: #fff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .25);
    overflow: hidden;
}

/* Diagonal sheen so the plate does not read as a flat rectangle. */
.opus-cc-face::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, 0) 45%);
    pointer-events: none;
}

.opus-cc-face--front {
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: 18px 20px;
}

.opus-cc-face--back {
    transform: rotateY(180deg);
    display: grid;
    grid-template-rows: 28px auto 1fr;
    padding: 18px 0 16px;
}

.opus-cc-pv-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

/* EMV chip */
.opus-cc-chip {
    width: 42px;
    height: 32px;
    border-radius: 6px;
    background: linear-gradient(135deg, #E8C874 0%, #C9A227 55%, #F3E0A0 100%);
    position: relative;
    flex: none;
}

.opus-cc-chip::before,
.opus-cc-chip::after {
    content: "";
    position: absolute;
    left: 6px;
    right: 6px;
    height: 1px;
    background: rgba(0, 0, 0, .28);
}

.opus-cc-chip::before { top: 11px; }
.opus-cc-chip::after { top: 20px; }

.opus-cc-pv-number {
    font-size: clamp(15px, 5vw, 20px);
    letter-spacing: .09em;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
    align-self: center;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

.opus-cc-pv-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.opus-cc-pv-caption {
    display: block;
    font-size: 8px;
    letter-spacing: .14em;
    text-transform: uppercase;
    opacity: .65;
    margin-bottom: 3px;
}

.opus-cc-pv-value {
    display: block;
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.opus-cc-pv-holder { min-width: 0; }
.opus-cc-pv-expiry { flex: none; text-align: right; }

.opus-cc-pv-stripe {
    grid-row: 2;
    height: 42px;
    background: #101828;
}

.opus-cc-pv-cvc-row {
    grid-row: 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px 0;
}

.opus-cc-pv-signature {
    flex: 1;
    height: 30px;
    border-radius: 4px;
    background: repeating-linear-gradient(135deg, #F1F5F9 0 6px, #E2E8F0 6px 12px);
}

.opus-cc-pv-cvc {
    min-width: 54px;
    height: 30px;
    border-radius: 4px;
    background: #fff;
    color: #101828;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    letter-spacing: .12em;
}

/* ── Brand mark ─────────────────────────────────────────────────────────── */

.opus-cc-brandmark {
    flex: none;
    height: 26px;
    display: flex;
    align-items: center;
    opacity: .95;
    transition: opacity .2s ease;
}

.opus-cc-brandmark:empty { opacity: 0; }
.opus-cc-brandmark svg { height: 100%; width: auto; display: block; }

/* ── Fields ─────────────────────────────────────────────────────────────── */

.opus-cc-fields {
    display: grid;
    gap: var(--opus-spacing-4, 16px);
    min-width: 0;
}

.opus-cc-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--opus-spacing-4, 16px);
}

.opus-cc-field { min-width: 0; }

.opus-cc-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: var(--opus-font-weight-medium, 500);
    color: var(--opus-color-text-heading, #0F172A);
}

.opus-cc-control { position: relative; }

.opus-cc-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 11px 14px;
    border: 1px solid var(--opus-color-border, #E2E8F0);
    border-radius: var(--opus-radius-md, 8px);
    background: var(--opus-color-bg-page, #fff);
    color: var(--opus-color-text-body, #334155);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.opus-cc-input::placeholder {
    color: var(--opus-color-text-muted, #64748B);
    opacity: .7;
}

.opus-cc-input:focus {
    outline: none;
    border-color: var(--opus-color-primary, #00237C);
    box-shadow: 0 0 0 3px rgba(0, 35, 124, .15);
}

.opus-cc-input--number,
.opus-cc-input--cvc {
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
}

/* Room for the inline brand mark. */
.opus-cc-input--number { padding-right: 62px; }

.opus-cc-input-brand {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    height: 20px;
    pointer-events: none;
}

.opus-cc-input-brand svg { height: 100%; width: auto; display: block; }

.opus-cc-input.opus-cc-input--invalid,
.opus-cc-input.input-validation-error {
    border-color: var(--opus-color-error, #E80000);
    box-shadow: 0 0 0 3px rgba(232, 0, 0, .12);
}

.opus-cc-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--opus-color-text-muted, #64748B);
}

/* Server-side (ModelState) and client-side messages share one look. */
.opus-cc-field .field-validation-error,
.opus-cc-message {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--opus-color-error, #E80000);
}

.opus-cc-message:empty { display: none; }

.opus-cc-secure-note {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--opus-color-text-muted, #64748B);
}

.opus-cc-secure-note svg {
    flex: none;
    width: 14px;
    height: 14px;
}

/* Extra plugin-specific fields (installments, saved cards, national id) reuse
   the field skeleton so they line up with the card block. */
.opus-cc-extra {
    display: grid;
    gap: var(--opus-spacing-4, 16px);
    margin-top: var(--opus-spacing-4, 16px);
}

.opus-cc-select {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 11px 14px;
    border: 1px solid var(--opus-color-border, #E2E8F0);
    border-radius: var(--opus-radius-md, 8px);
    background: var(--opus-color-bg-page, #fff);
    color: var(--opus-color-text-body, #334155);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
}

.opus-cc-select:focus {
    outline: none;
    border-color: var(--opus-color-primary, #00237C);
    box-shadow: 0 0 0 3px rgba(0, 35, 124, .15);
}

.opus-cc-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--opus-color-text-body, #334155);
}

@media (max-width: 480px) {
    .opus-cc-row { grid-template-columns: 1fr; }
}
