/* ============================================================
   PS Fraud Protector — Modal
   Petratide Montserrat-Glassmorphic Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');
/* Great Vibes (cursive signature font) is enqueued separately in PHP as a
   proper stylesheet so CSS minifiers don't strip it and it loads in time
   for the canvas signature render. */

#psfp-overlay,
#psfp-modal,
#psfp-modal * {
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
}

/* ── Overlay ─────────────────────────────────────────────────────────────
   pointer-events: auto when active → catches all clicks behind the modal,
   blocking interaction with the checkout page until the modal is dismissed
   or consent is given. Page scroll is also blocked (body gets psfp-locked). */
#psfp-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(14, 12, 26, 0.82) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 2147483640 !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
}

#psfp-overlay.psfp-active {
    opacity: 1 !important;
    pointer-events: auto !important;  /* blocks clicks to page behind */
}

/* When the modal is open, prevent the body from scrolling. The modal itself
   has its own internal scroll if its content overflows. */
body.psfp-locked {
    overflow: hidden !important;
}

/* ── Modal container ───────────────────────────────────────── */
#psfp-modal {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 2147483647 !important;
    width: 94%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    pointer-events: auto !important;
    overscroll-behavior: contain;
    animation: psfpFadeUp 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
    scrollbar-width: thin;
    scrollbar-color: rgba(164,63,255,0.35) transparent;
}

#psfp-modal::-webkit-scrollbar        { width: 5px; }
#psfp-modal::-webkit-scrollbar-track  { background: transparent; }
#psfp-modal::-webkit-scrollbar-thumb  { background: rgba(164,63,255,0.35); border-radius: 3px; }

@keyframes psfpFadeUp {
    from { opacity: 0; transform: translate(-50%, -46%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* ── Inner card ────────────────────────────────────────────── */
.psfp-inner {
    background: rgba(18, 14, 36, 0.97);
    border: 1px solid rgba(164, 63, 255, 0.25);
    border-radius: 22px;
    padding: 38px 40px 36px;
    box-shadow:
        0 28px 80px rgba(0, 0, 0, 0.65),
        inset 0 1px 0 rgba(164, 63, 255, 0.18);
    width: 100%;
}

/* ── Header (NO divider line — header has its own bottom margin) ────── */
.psfp-header {
    margin-bottom: 22px;
}

.psfp-header h2 {
    margin: 0 0 10px;
    font-size: 21px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.3px;
    background: linear-gradient(130deg, #ffffff 55%, #c280ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.psfp-subtext {
    margin: 0;
    font-size: 13.5px;
    color: #9b90b8;
    line-height: 1.65;
}

/* ── Consent list ──────────────────────────────────────────── */
.psfp-consent-list {
    list-style: none;
    padding: 0;
    margin: 0 0 22px;
}

.psfp-consent-list li {
    position: relative;
    padding: 8px 0 8px 26px;
    font-size: 13px;
    color: #c4b8e0;
    line-height: 1.55;
    border-bottom: 1px solid rgba(164, 63, 255, 0.08);
}

.psfp-consent-list li:last-child { border-bottom: none; }

.psfp-consent-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 9px;
    color: #a43fff;
    font-size: 12px;
    font-weight: 700;
}

/* ── Order summary ─────────────────────────────────────────── */
.psfp-summary {
    background: rgba(164, 63, 255, 0.05);
    border: 1px solid rgba(164, 63, 255, 0.18);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 24px;
}

.psfp-summary-label {
    display: block;
    margin-bottom: 14px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: #a43fff;
}

.psfp-items {
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(164, 63, 255, 0.14);
}

.psfp-item-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 5px 0;
    gap: 12px;
}

.psfp-item-name { font-size: 13px; color: #d4c8f0; flex: 1; min-width: 0; word-break: break-word; }
.psfp-item-qty  { font-size: 12px; color: #7a6e96; margin-left: 5px; }
.psfp-item-price { font-size: 13px; color: #ffffff; font-weight: 600; white-space: nowrap; }

.psfp-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
    color: #9b90b8;
    gap: 12px;
}

.psfp-total-row span:last-child { color: #d0c4ee; font-weight: 500; white-space: nowrap; }

.psfp-grand-total {
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid rgba(164, 63, 255, 0.2);
    font-size: 15.5px !important;
    font-weight: 700;
    color: #ffffff !important;
}

.psfp-grand-total span { color: #ffffff !important; font-weight: 700; }

/* ── Checkbox ──────────────────────────────────────────────── */
.psfp-check-wrap { margin-bottom: 26px; }

.psfp-check-label {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    cursor: pointer;
    user-select: none;
}

.psfp-check-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.psfp-box {
    flex-shrink: 0;
    width: 21px;
    height: 21px;
    min-width: 21px;
    margin-top: 1px;
    background: rgba(164, 63, 255, 0.08);
    border: 2px solid rgba(164, 63, 255, 0.45);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.psfp-check-label input:checked ~ .psfp-box {
    background: #a43fff;
    border-color: #a43fff;
}

.psfp-box::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: 2.5px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) scaleY(0);
    transform-origin: bottom center;
    margin-top: -2px;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.psfp-check-label input:checked ~ .psfp-box::after {
    transform: rotate(45deg) scaleY(1);
}

.psfp-check-text { font-size: 13px; color: #c4b8e0; line-height: 1.6; }

/* ── Signature Pad ──────────────────────────────────────────────────────
   Intentionally NOT glassmorphic — clean white card with black border so
   the signature is highly visible and exports cleanly to PNG.            */
.psfp-sig-wrap {
    margin-bottom: 24px;
}

.psfp-sig-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.psfp-sig-label {
    font-size: 12px;
    font-weight: 600;
    color: #c4b8e0;
    letter-spacing: 0.3px;
}

.psfp-sig-required {
    color: #ff6b6b;
    margin-left: 2px;
}

.psfp-sig-clear {
    background: rgba(164, 63, 255, 0.1);
    border: 1px solid rgba(164, 63, 255, 0.25);
    color: #c280ff;
    padding: 5px 12px;
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.psfp-sig-clear:hover {
    background: rgba(164, 63, 255, 0.2);
    color: #ffffff;
}

.psfp-sig-pad {
    position: relative;
    background: #ffffff;
    border: 2px solid #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    height: 160px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.psfp-sig-pad canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Ensure modal action buttons stay above any sig-pad layers and remain clickable
   even after pointer capture events. The signature pad is contained to its own
   element so its event capture never extends past .psfp-sig-pad. */
.psfp-actions {
    position: relative;
    z-index: 10;
}
.psfp-actions .psfp-btn {
    pointer-events: auto;
}

.psfp-sig-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    color: #999;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    user-select: none;
}

@media (max-width: 520px) {
    .psfp-sig-pad { height: 140px; }
}

/* ── Signature mode toggle (choice mode) ──────────────────────────────── */
.psfp-sig-mode-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    background: rgba(164, 63, 255, 0.06);
    border: 1px solid rgba(164, 63, 255, 0.18);
    border-radius: 10px;
    padding: 4px;
}
.psfp-sig-mode-btn {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: #9b90b8;
    font-family: 'Montserrat', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.psfp-sig-mode-btn.psfp-sig-mode-active {
    background: linear-gradient(135deg, #a43fff 0%, #7b2fd4 100%);
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(164, 63, 255, 0.35);
}

/* ── Type mode (cursive typed signature) ──────────────────────────────── */
.psfp-sig-typed-input {
    width: 100%;
    padding: 13px 16px;
    background: #ffffff;
    border: 2px solid #1a1a1a;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px dashed #bbb;
    color: #111111;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
}
.psfp-sig-typed-input::placeholder { color: #aaa; }
.psfp-sig-typed-input:focus { border-color: #a43fff; }

/* Live cursive preview area — renders what gets saved as the signature */
.psfp-sig-type-preview {
    width: 100%;
    min-height: 90px;
    background: #ffffff;
    border: 2px solid #1a1a1a;
    border-top: none;
    border-radius: 0 0 12px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Great Vibes', 'Brush Script MT', cursive;
    font-size: 42px;
    line-height: 1.1;
    color: #111111;
    padding: 10px 16px;
    box-sizing: border-box;
    word-break: break-word;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

@media (max-width: 520px) {
    .psfp-sig-type-preview { font-size: 34px; min-height: 76px; }
}

/* ── Buttons ───────────────────────────────────────────────── */
.psfp-actions { display: flex; gap: 12px; }

.psfp-btn {
    flex: 1;
    min-width: 0;
    padding: 13px 18px;
    border: none;
    border-radius: 11px;
    font-family: 'Montserrat', sans-serif;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.15px;
    cursor: pointer;
    transition: background 0.22s ease, box-shadow 0.22s ease, transform 0.18s ease, color 0.18s ease;
    white-space: nowrap;
}

.psfp-btn-back {
    background: rgba(164, 63, 255, 0.09);
    border: 1px solid rgba(164, 63, 255, 0.22);
    color: #9b90b8;
}

.psfp-btn-back:hover {
    background: rgba(164, 63, 255, 0.17);
    color: #c280ff;
}

.psfp-btn-complete {
    background: rgba(164, 63, 255, 0.12);
    border: 1px solid rgba(164, 63, 255, 0.15);
    color: rgba(164, 63, 255, 0.35);
    cursor: not-allowed;
}

/* Disabled state — explicitly no interactive feedback until checkbox is checked.
   We override hover/focus/active so no theme or browser default can introduce
   any visual change while the button is in its disabled state. */
.psfp-btn-complete:not(.psfp-enabled),
.psfp-btn-complete:not(.psfp-enabled):hover,
.psfp-btn-complete:not(.psfp-enabled):focus,
.psfp-btn-complete:not(.psfp-enabled):focus-visible,
.psfp-btn-complete:not(.psfp-enabled):active {
    background: rgba(164, 63, 255, 0.12) !important;
    border: 1px solid rgba(164, 63, 255, 0.15) !important;
    color: rgba(164, 63, 255, 0.35) !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    transition: none !important;
    outline: none !important;
}

.psfp-btn-complete.psfp-enabled {
    background: linear-gradient(135deg, #a43fff 0%, #7b2fd4 100%);
    border-color: transparent;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 6px 22px rgba(164, 63, 255, 0.42);
}

.psfp-btn-complete.psfp-enabled:hover {
    box-shadow: 0 10px 32px rgba(164, 63, 255, 0.55);
    transform: translateY(-2px);
}

.psfp-btn-complete.psfp-enabled:active {
    transform: translateY(0);
    box-shadow: 0 4px 14px rgba(164, 63, 255, 0.35);
}

.psfp-btn-complete.psfp-loading { opacity: 0.7; cursor: wait; }

/* ── Error ─────────────────────────────────────────────────── */
.psfp-error {
    margin-top: 14px;
    padding: 11px 15px;
    background: rgba(255, 60, 60, 0.1);
    border: 1px solid rgba(255, 60, 60, 0.28);
    border-radius: 8px;
    font-size: 13px;
    color: #ff8c8c;
    line-height: 1.5;
}

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    #psfp-modal { max-width: 520px; }
    .psfp-inner { padding: 32px 28px 28px; border-radius: 18px; }
    .psfp-header h2 { font-size: 19px; }
}

@media (max-width: 520px) {
    #psfp-modal {
        width: calc(100% - 20px);
    }
    .psfp-inner { padding: 26px 20px 24px; border-radius: 16px; }
    .psfp-header { margin-bottom: 18px; }
    .psfp-header h2 { font-size: 17px; line-height: 1.3; }
    .psfp-subtext { font-size: 12.5px; }
    .psfp-consent-list li { padding: 7px 0 7px 22px; font-size: 12.5px; }
    .psfp-consent-list li::before { top: 8px; font-size: 11px; }
    .psfp-summary { padding: 14px 16px; margin-bottom: 20px; }
    .psfp-item-name, .psfp-item-price, .psfp-total-row { font-size: 12.5px; }
    .psfp-grand-total { font-size: 14.5px !important; }
    .psfp-check-text { font-size: 12.5px; }
    .psfp-actions { flex-direction: column-reverse; gap: 10px; }
    .psfp-btn { padding: 14px 16px; font-size: 13px; }
}

@media (max-width: 360px) {
    .psfp-inner { padding: 22px 16px 20px; }
    .psfp-header h2 { font-size: 16px; }
    .psfp-summary { padding: 12px 14px; }
    .psfp-box { width: 19px; height: 19px; min-width: 19px; }
}

@media (max-height: 600px) {
    .psfp-inner { padding: 22px 28px 22px; }
    .psfp-header { margin-bottom: 14px; }
    .psfp-summary { padding: 14px 18px; margin-bottom: 18px; }
    .psfp-check-wrap { margin-bottom: 18px; }
}
