/**
 * WC Quick Buy Pro — Frontend Styles
 * Dynamic (user-configured) values are injected via wp_head.
 * This file handles structure, layout, animation, and responsiveness only.
 */

/* ============================================================
   BUTTON
   ============================================================ */
.wc-qbp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    border: none;
    margin-top: 10px;
    text-transform: capitalize;
    text-decoration: none;
    line-height: 1.4;
    transition: background 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.wc-qbp-button:active {
    transform: scale(0.97);
}

.wc-qbp-button .wc-qbp-icon {
    display: inline-flex;
    line-height: 1;
    flex-shrink: 0;
}

.wc-qbp-button .wc-qbp-text {
    display: inline-block;
}

/* ============================================================
   MODAL — BACKDROP
   ============================================================ */
.wc-qbp-modal {
    position: fixed;
    inset: 0;                       /* top/right/bottom/left: 0 */
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;                  /* safety gap from viewport edges */
    box-sizing: border-box;
}

/* Hidden state — use hidden attr + this class for CSS animation */
.wc-qbp-modal[hidden] {
    display: none;
}

.wc-qbp-overlay {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    cursor: pointer;
}

/* ============================================================
   MODAL — DIALOG PANEL
   ============================================================ */
.wc-qbp-dialog {
    position: relative;
    width: 100%;
    /* max-width set dynamically */
    max-height: calc(100dvh - 32px); /* dynamic viewport height — safe on mobile */
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 1;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;

    /* Entrance animation */
    animation: qbp-slide-in 0.22s ease-out both;
}

@keyframes qbp-slide-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)     scale(1); }
}

/* ============================================================
   CLOSE BUTTON
   ============================================================ */
.wc-qbp-close {
    position: sticky;
    top: 0;
    float: right;
    margin: -8px -8px 0 0;       /* pull into padding area */
    width: 34px;
    height: 34px;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.wc-qbp-close:hover  { background: rgba(0,0,0,0.12); color: #000; }
.wc-qbp-close:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* ============================================================
   TITLE
   ============================================================ */
.wc-qbp-title {
    margin: 0 0 20px 0;
    font-family: inherit;
    line-height: 1.2;
    text-transform: capitalize;
    /* color / size / weight set dynamically */
}

/* ============================================================
   FORM
   ============================================================ */
#wc-qbp-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wc-qbp-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wc-qbp-field label {
    display: block;
    text-transform: capitalize;
    /* color / size / weight set dynamically */
}

/* ============================================================
   INPUTS & TEXTAREA
   ============================================================ */
.wc-qbp-field input,
.wc-qbp-field textarea {
    width: 100%;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    font-family: inherit;
    color: #444;
    box-sizing: border-box;
    transition: background 0.15s ease;
    /* bg / radius / padding / font-size set dynamically */
}

.wc-qbp-field input::placeholder,
.wc-qbp-field textarea::placeholder {
    color: #aaa;
    font-weight: 400;
}

.wc-qbp-field textarea {
    resize: vertical;
    min-height: 110px;
    line-height: 1.6;
}

/* ============================================================
   SUBMIT BUTTON
   ============================================================ */
.wc-qbp-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    border: none;
    width: 100%;
    margin-top: 4px;
    text-transform: capitalize;
    transition: background 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    box-sizing: border-box;
}

.wc-qbp-submit:active { transform: scale(0.98); }

.wc-qbp-submit:disabled,
.wc-qbp-submit.loading {
    opacity: 0.65;
    cursor: not-allowed;
    pointer-events: none;
}

/* Loading spinner */
.wc-qbp-submit.loading .wc-qbp-icon,
.wc-qbp-submit.loading .wc-qbp-text { opacity: 0; }

.wc-qbp-submit.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: qbp-spin 0.55s linear infinite;
}

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

/* ============================================================
   FEEDBACK MESSAGES
   ============================================================ */
.wc-qbp-message {
    display: none;
    padding: 13px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.wc-qbp-message.is-success {
    display: block;
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.wc-qbp-message.is-error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.wc-qbp-message.is-success::before { content: '✓  '; font-weight: 700; }
.wc-qbp-message.is-error::before   { content: '⚠  '; font-weight: 700; }

/* ============================================================
   CUSTOM SCROLLBAR (Webkit)
   ============================================================ */
.wc-qbp-dialog::-webkit-scrollbar       { width: 6px; }
.wc-qbp-dialog::-webkit-scrollbar-track { background: transparent; }
.wc-qbp-dialog::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.wc-qbp-dialog::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ============================================================
   RESPONSIVE — TABLET (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
    .wc-qbp-modal {
        padding: 16px;
        align-items: center;
        justify-content: center;
    }

    .wc-qbp-dialog {
        width: 100%;
        max-width: 92vw !important;
        max-height: 90dvh;
    }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
    .wc-qbp-modal {
        padding: 12px;
    }

    .wc-qbp-dialog {
        max-width: 100% !important;
        max-height: 92dvh;
    }

    #wc-qbp-form {
        gap: 12px;
    }

    .wc-qbp-field textarea {
        min-height: 90px;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .wc-qbp-dialog,
    .wc-qbp-button,
    .wc-qbp-submit { animation: none; transition: none; }
}
