/*
 * MexPay Frontend Styles — Premium iOS-like dark product widgets
 * Copyright (c) 2026 MexTech Limited. All Rights Reserved.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --mp-bg:          #0a0a0a;
    --mp-surface:     #111111;
    --mp-surface2:    #181818;
    --mp-border:      #242424;
    --mp-green:       #5a7a3a;
    --mp-green-l:     #6d9445;
    --mp-green-d:     #3d5427;
    --mp-green-glow:  rgba(90,122,58,0.15);
    --mp-text:        #f0f0f0;
    --mp-text-2:      #a0a0a0;
    --mp-text-3:      #555;
    --mp-radius:      14px;
    --mp-radius-sm:   8px;
    --mp-font:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mp-shadow:      0 8px 32px rgba(0,0,0,.5);
}

.mexpay-wrapper * { box-sizing: border-box; font-family: var(--mp-font); }

/* ── Grid ── */
.mexpay-wrapper { width: 100%; }

.mexpay-grid {
    display: grid;
    grid-template-columns: repeat(var(--mexpay-cols, 3), 1fr);
    gap: 20px;
}

/* ── Product Card ── */
.mexpay-card {
    background: var(--mp-surface);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    overflow: hidden;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
    display: flex;
    flex-direction: column;
}

.mexpay-card:hover {
    transform: translateY(-4px);
    border-color: var(--mp-green-d);
    box-shadow: 0 16px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(90,122,58,.1);
}

.mexpay-card-image {
    width: 100%;
    aspect-ratio: 16/10;
    overflow: hidden;
    background: var(--mp-surface2);
    flex-shrink: 0;
}

.mexpay-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .4s ease;
}

.mexpay-card:hover .mexpay-card-image img {
    transform: scale(1.04);
}

.mexpay-card-body {
    padding: 16px 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mexpay-sku {
    font-size: 10.5px;
    color: var(--mp-text-3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    font-family: 'SF Mono', monospace;
    display: block;
    margin-bottom: 6px;
}

.mexpay-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--mp-text);
    margin: 0 0 6px;
    line-height: 1.3;
    letter-spacing: -0.2px;
}

.mexpay-card-desc {
    font-size: 13px;
    color: var(--mp-text-2);
    margin: 0 0 14px;
    line-height: 1.6;
    flex: 1;
}

.mexpay-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
}

.mexpay-price {
    font-size: 20px;
    font-weight: 800;
    color: var(--mp-green-l);
    letter-spacing: -0.8px;
    line-height: 1;
}

.mexpay-buy-btn {
    background: var(--mp-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--mp-font);
    cursor: pointer;
    letter-spacing: 0.2px;
    transition: background .2s, transform .1s;
    white-space: nowrap;
}

.mexpay-buy-btn:hover { background: var(--mp-green-l); }
.mexpay-buy-btn:active { transform: scale(.97); }

/* Empty state */
.mexpay-empty {
    text-align: center;
    color: var(--mp-text-3);
    padding: 40px;
    font-size: 14px;
}

/* ── Modal overlay ── */
.mexpay-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mexpay-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: mp-fade-in .2s ease;
}

.mexpay-modal-box {
    position: relative;
    background: var(--mp-surface);
    border: 1px solid var(--mp-border);
    border-radius: 18px;
    padding: 32px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--mp-shadow);
    animation: mp-slide-up .25s cubic-bezier(.25,.46,.45,.94);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes mp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes mp-slide-up {
    from { opacity: 0; transform: translateY(20px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.mexpay-modal-close {
    position: absolute;
    top: 16px; right: 16px;
    width: 30px; height: 30px;
    background: var(--mp-surface2);
    border: 1px solid var(--mp-border);
    border-radius: 50%;
    color: var(--mp-text-2);
    font-size: 18px;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    display: flex; align-items: center; justify-content: center;
}

.mexpay-modal-close:hover {
    background: var(--mp-border);
    color: var(--mp-text);
}

.mexpay-modal-header {
    margin-bottom: 24px;
}

.mexpay-brand {
    font-size: 11px;
    font-weight: 700;
    color: var(--mp-green);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.mexpay-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--mp-text);
    margin: 0 0 6px;
    letter-spacing: -0.4px;
}

.mexpay-modal-price {
    font-size: 28px;
    font-weight: 800;
    color: var(--mp-green-l);
    margin: 0;
    letter-spacing: -1px;
}

/* ── Form ── */
#mexpay-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mexpay-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--mp-text-2);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 6px;
}

.mexpay-req { color: #c0392b; }

.mexpay-field input {
    width: 100%;
    background: var(--mp-surface2);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius-sm);
    color: var(--mp-text);
    font-size: 14px;
    font-family: var(--mp-font);
    padding: 11px 14px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
}

.mexpay-field input:focus {
    border-color: var(--mp-green);
    box-shadow: 0 0 0 3px var(--mp-green-glow);
}

.mexpay-field input::placeholder { color: var(--mp-text-3); }

.mexpay-error {
    background: rgba(192,57,43,.12);
    border: 1px solid rgba(192,57,43,.4);
    color: #e74c3c;
    border-radius: var(--mp-radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}

.mexpay-pay-btn {
    width: 100%;
    background: var(--mp-green);
    color: #fff;
    border: none;
    border-radius: var(--mp-radius-sm);
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--mp-font);
    cursor: pointer;
    letter-spacing: 0.2px;
    transition: background .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
}

.mexpay-pay-btn:hover:not(:disabled) { background: var(--mp-green-l); }
.mexpay-pay-btn:disabled { opacity: .6; cursor: not-allowed; }

.mexpay-btn-spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mp-spin .7s linear infinite;
}
@keyframes mp-spin { to { transform: rotate(360deg); } }

.mexpay-secure-note {
    text-align: center;
    color: var(--mp-text-3);
    font-size: 11.5px;
    margin: 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mexpay-secure-note strong { color: var(--mp-text-2); }

/* ── Success overlay ── */
.mexpay-success-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    background: rgba(0,0,0,.9);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    padding: 20px;
}

.mexpay-success-box {
    background: var(--mp-surface);
    border: 1px solid var(--mp-green-d);
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    max-width: 360px;
    width: 100%;
    animation: mp-slide-up .3s ease;
}

.mexpay-success-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    border: 3px solid var(--mp-green);
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mexpay-success-icon svg {
    width: 52px; height: 52px;
    display: block;
}

.mexpay-success-icon svg circle {
    stroke: var(--mp-green);
    stroke-dasharray: 160;
    stroke-dashoffset: 160;
    animation: mp-draw-circle 0.6s ease forwards;
}

.mexpay-success-icon svg path {
    stroke: var(--mp-green);
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: mp-draw-check 0.4s ease 0.5s forwards;
}

@keyframes mp-draw-circle {
    to { stroke-dashoffset: 0; }
}
@keyframes mp-draw-check {
    to { stroke-dashoffset: 0; }
}

.mexpay-success-box h3 {
    color: var(--mp-text);
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 10px;
}

.mexpay-success-box p {
    color: var(--mp-text-2);
    font-size: 14px;
    margin: 0 0 24px;
    line-height: 1.6;
}

/* ── Floating style ── */
.mexpay-style-float .mexpay-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}

.mexpay-style-float .mexpay-card {
    width: 260px;
    flex-shrink: 0;
}

/* ── Minimal style ── */
.mexpay-style-minimal .mexpay-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mexpay-style-minimal .mexpay-card {
    flex-direction: row;
    border-radius: var(--mp-radius-sm);
}

.mexpay-style-minimal .mexpay-card-image {
    width: 100px;
    min-width: 100px;
    aspect-ratio: 1;
    flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .mexpay-grid {
        grid-template-columns: repeat(min(var(--mexpay-cols, 3), 2), 1fr) !important;
    }
}

@media (max-width: 480px) {
    .mexpay-grid { grid-template-columns: 1fr !important; }
    .mexpay-modal-box { padding: 24px 20px; border-radius: 16px 16px 0 0; align-self: flex-end; width: 100%; max-width: 100%; }
    .mexpay-modal { align-items: flex-end; padding: 0; }
}

/* ══════════════════════════════════════════════════════════
 * FRONTEND TOAST NOTICE SYSTEM
 * ══════════════════════════════════════════════════════════ */
#mexpay-toast-wrap {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    width: 100%;
    max-width: 440px;
    padding: 0 16px;
}

.mexpay-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #0f0f0f;
    border: 1px solid #252525;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4);
    pointer-events: all;
    width: 100%;
    opacity: 0;
    transform: translateY(16px) scale(.97);
    transition: opacity .28s ease, transform .28s ease;
    position: relative;
    overflow: hidden;
}

.mexpay-toast::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
}

.mexpay-toast.mexpay-toast-in  { opacity: 1; transform: translateY(0) scale(1); }
.mexpay-toast.mexpay-toast-out { opacity: 0; transform: translateY(8px) scale(.97); transition: opacity .3s ease, transform .3s ease; }

.mexpay-toast-success::before { background: #5a7a3a; }
.mexpay-toast-success .mexpay-toast-icon { color: #6d9445; }

.mexpay-toast-error::before { background: #c0392b; }
.mexpay-toast-error .mexpay-toast-icon { color: #e74c3c; }

.mexpay-toast-warning::before { background: #d4a017; }
.mexpay-toast-warning .mexpay-toast-icon { color: #d4a017; }

.mexpay-toast-info::before { background: #444; }
.mexpay-toast-info .mexpay-toast-icon { color: #888; }

.mexpay-toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-top: 1px;
}

.mexpay-toast-text {
    flex: 1;
    font-size: 14px;
    color: #e8e8e8;
    line-height: 1.55;
    font-family: var(--mp-font);
}

.mexpay-toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #444;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: color .15s;
    align-self: flex-start;
}
.mexpay-toast-close:hover { color: #888; }

@media (max-width: 480px) {
    #mexpay-toast-wrap { bottom: 16px; padding: 0 12px; }
}

/* ══════════════════════════════════════════════════════════
 * AUTO-DISPLAY HOMEPAGE WIDGET
 * ══════════════════════════════════════════════════════════ */
.mexpay-hw {
    --hw-bg:      #111111;
    --hw-border:  #222222;
    --hw-radius:  14px;
    --hw-green:   #5a7a3a;
    --hw-green-l: #6d9445;
    --hw-text:    #f0f0f0;
    --hw-text-2:  #a0a0a0;
    --hw-shadow:  0 20px 60px rgba(0,0,0,.55), 0 4px 16px rgba(0,0,0,.35);
    --hw-font:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    background: var(--hw-bg);
    border: 1px solid var(--hw-border);
    border-radius: var(--hw-radius);
    box-shadow: var(--hw-shadow);
    display: inline-flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--hw-font);
    height: fit-content;

    /* entrance: hidden by default, shown via JS */
    opacity: 0;
    transform: translateY(16px) scale(.97);
    transition: opacity .32s cubic-bezier(.25,.46,.45,.94),
                transform .32s cubic-bezier(.25,.46,.45,.94);
}

.mexpay-hw[hidden] { display: none !important; }

.mexpay-hw.mexpay-hw-in {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.mexpay-hw.mexpay-hw-out {
    opacity: 0;
    transform: translateY(12px) scale(.97);
    transition: opacity .28s ease, transform .28s ease;
}

/* ── Header ── */
.mexpay-hw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px 12px;
    border-bottom: 1px solid var(--hw-border);
    flex-shrink: 0;
}

.mexpay-hw-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--hw-text);
    letter-spacing: -0.1px;
}

.mexpay-hw-close {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.05);
    color: var(--hw-text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s;
    padding: 0;
}
.mexpay-hw-close:hover {
    background: rgba(255,255,255,.1);
    color: var(--hw-text);
}

/* ── Body + scroll ── */
.mexpay-hw-body {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px;
    flex: 0 1 auto;
    -webkit-overflow-scrolling: touch;
}

/* Thin custom scrollbar */
.mexpay-hw-body::-webkit-scrollbar { width: 4px; }
.mexpay-hw-body::-webkit-scrollbar-track { background: transparent; }
.mexpay-hw-body::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }
.mexpay-hw-body::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* ── Grid ── */
.mexpay-hw-grid {
    display: grid;
    gap: 10px;
}
.mexpay-hw-cols-1 { grid-template-columns: 1fr; }
.mexpay-hw-cols-2 { grid-template-columns: 1fr 1fr; }
.mexpay-hw-cols-3 { grid-template-columns: repeat(3, 1fr); }

/* ── Item: grid card style ── */
.mexpay-hw-style-grid .mexpay-hw-item {
    background: #161616;
    border: 1px solid var(--hw-border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color .2s, transform .2s;
}
.mexpay-hw-style-grid .mexpay-hw-item:hover {
    border-color: #2e2e2e;
    transform: translateY(-2px);
}

.mexpay-hw-item-img {
    width: 100%;
    padding-top: 68%;
    background-size: cover;
    background-position: center;
    background-color: #1a1a1a;
    flex-shrink: 0;
}

.mexpay-hw-item-body {
    padding: 10px 10px 6px;
    flex: 1;
}

.mexpay-hw-item-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--hw-text);
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mexpay-hw-item-price {
    font-size: 12px;
    font-weight: 700;
    color: var(--hw-green-l);
    margin-bottom: 2px;
}

.mexpay-hw-item-desc {
    font-size: 11px;
    color: var(--hw-text-2);
    line-height: 1.5;
    margin-bottom: 4px;
}

.mexpay-hw-buy {
    display: block;
    width: calc(100% - 20px);
    margin: 0 10px 10px;
    padding: 7px 12px;
    background: var(--hw-green);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--hw-font);
    cursor: pointer;
    transition: background .15s, transform .1s;
    text-align: center;
}
.mexpay-hw-buy:hover {
    background: var(--hw-green-l);
    transform: scale(1.02);
}
.mexpay-hw-buy:active { transform: scale(.98); }

/* ── Item: minimal list style ── */
.mexpay-hw-style-minimal .mexpay-hw-grid { gap: 0; }

.mexpay-hw-style-minimal .mexpay-hw-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--hw-border);
    transition: background .15s;
}
.mexpay-hw-style-minimal .mexpay-hw-item:last-child { border-bottom: none; }
.mexpay-hw-style-minimal .mexpay-hw-item:hover { background: rgba(255,255,255,.02); }

.mexpay-hw-style-minimal .mexpay-hw-item-img {
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding-top: 0;
    border-radius: 8px;
    flex-shrink: 0;
}

.mexpay-hw-style-minimal .mexpay-hw-item-body { flex: 1; }
.mexpay-hw-style-minimal .mexpay-hw-item-name  { font-size: 13px; margin-bottom: 2px; }
.mexpay-hw-style-minimal .mexpay-hw-item-price { font-size: 12px; }

.mexpay-hw-style-minimal .mexpay-hw-buy {
    width: auto;
    margin: 0;
    padding: 6px 14px;
    flex-shrink: 0;
    white-space: nowrap;
    border-radius: 7px;
}

/* ── Mobile: collapse to 1 col on small screens and pin bottom ── */
@media (max-width: 480px) {
    .mexpay-hw {
        max-width: calc(100vw - 16px) !important;
    }
    .mexpay-hw-cols-2,
    .mexpay-hw-cols-3 { grid-template-columns: 1fr; }

    /* Override fixed position to full-width bottom bar on very small screens */
    .mexpay-hw[style*="bottom"] {
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        transform: none !important;
    }
}

/* ── Product type badges on cards ── */
.mexpay-card-image { position: relative; }
.mexpay-type-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    pointer-events: none;
}
.mexpay-type-physical { background: rgba(30,40,20,.75);  color: #a0d060; border: 1px solid rgba(100,160,50,.4); }
.mexpay-type-digital  { background: rgba(20,30,55,.75);  color: #7aadff; border: 1px solid rgba(80,130,220,.4); }
.mexpay-type-service  { background: rgba(50,30,10,.75);  color: #ffb870; border: 1px solid rgba(200,130,50,.4); }

/* ── Download button inside success overlay ── */
.mexpay-download-btn {
    background: linear-gradient(135deg, #3d6ea8, #2a4f7a) !important;
    margin-top: 10px !important;
}
.mexpay-download-btn:hover { background: linear-gradient(135deg, #4a80c0, #34608e) !important; }
