/*
 * Arshital Price Gallery — Luxury UI layer
 * v1.3.1
 * Designed to inherit WoodMart typography + primary color while keeping
 * a calm, editorial, warm-neutral visual language.
 */

.apg-root {
    --apg-accent: var(--wd-primary-color, #9b8562);
    --apg-title: var(--wd-title-color, #24231f);
    --apg-text: var(--wd-text-color, #4c4a44);
    --apg-muted: #858078;
    --apg-surface: #ffffff;
    --apg-surface-warm: #f6f3ed;
    --apg-surface-soft: #fbfaf7;
    --apg-border: rgba(45, 41, 34, .10);
    --apg-border-strong: rgba(45, 41, 34, .16);
    --apg-danger: #a43d35;
    --apg-success: #3e7550;
    --apg-radius-sm: 12px;
    --apg-radius-md: 18px;
    --apg-radius-lg: 26px;
    --apg-shadow: 0 32px 100px rgba(25, 22, 18, .22);
    width: 100%;
    color: var(--apg-text);
    font-family: inherit;
}

/* ---------- Main CTA on product page ---------- */
.apg-open-button {
    width: 100%;
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    border: 1px solid var(--apg-accent);
    border-radius: 999px;
    padding: 13px 24px;
    cursor: pointer;
    background: var(--apg-accent);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.4;
    letter-spacing: -.01em;
    box-shadow: 0 8px 24px rgba(36, 32, 26, .08);
    transition: transform .22s ease, box-shadow .22s ease, opacity .22s ease;
    -webkit-tap-highlight-color: transparent;
}

.apg-open-button:hover {
    color: #fff;
    opacity: .94;
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(36, 32, 26, .13);
}

.apg-open-button:active {
    transform: translateY(0);
    box-shadow: 0 6px 18px rgba(36, 32, 26, .10);
}

.apg-open-button:focus-visible,
.apg-order-trigger:focus-visible,
.apg-submit-button:focus-visible,
.apg-order-back:focus-visible,
.apg-close-button:focus-visible,
.apg-nav-button:focus-visible,
.apg-archive-trigger:focus-visible {
    outline: 2px solid var(--apg-accent);
    outline-offset: 3px;
}

.apg-button-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex: 0 0 auto;
    opacity: .92;
}

/* ---------- Modal shell ---------- */
.apg-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.apg-modal.is-open {
    display: flex;
    animation: apg-fade-in .20s ease both;
}

.apg-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(25, 23, 20, .66);
    backdrop-filter: blur(7px) saturate(.9);
    -webkit-backdrop-filter: blur(7px) saturate(.9);
}

.apg-dialog {
    position: relative;
    z-index: 1;
    width: min(1480px, 96vw);
    max-height: 94vh;
    overflow: hidden;
    background: var(--apg-surface);
    color: var(--apg-text);
    border: 1px solid rgba(255,255,255,.35);
    border-radius: var(--apg-radius-lg);
    box-shadow: var(--apg-shadow);
    direction: rtl;
    animation: apg-dialog-in .24s cubic-bezier(.2,.75,.25,1) both;
}

.apg-header {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 20px 14px 24px;
    border-bottom: 1px solid var(--apg-border);
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.apg-heading-wrap {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.apg-title {
    margin: 0;
    color: var(--apg-title);
    font: inherit;
    font-size: clamp(18px, 1.55vw, 24px);
    line-height: 1.55;
    font-weight: 700;
    letter-spacing: -.02em;
}

.apg-counter-mobile {
    display: none;
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--apg-muted);
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

.apg-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.apg-order-trigger,
.apg-submit-button,
.apg-order-back {
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.apg-order-trigger {
    min-height: 44px;
    padding: 9px 18px;
    border: 1px solid var(--apg-accent);
    border-radius: 999px;
    background: var(--apg-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.4;
    white-space: nowrap;
    transition: opacity .2s ease, transform .2s ease, box-shadow .2s ease;
}

.apg-order-trigger:hover,
.apg-submit-button:hover {
    color: #fff;
    opacity: .94;
    transform: translateY(-1px);
}

.apg-close-button,
.apg-nav-button {
    border: 0;
    color: inherit;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.apg-close-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--apg-border);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--apg-surface-soft);
    color: var(--apg-title);
    flex: 0 0 auto;
    transition: background .18s ease, transform .18s ease;
}

.apg-close-button:hover {
    background: #f0ede7;
    transform: rotate(3deg);
}

.apg-close-glyph {
    display: block;
    width: 100%;
    height: 100%;
    color: currentColor;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 29px;
    font-weight: 300;
    line-height: 38px;
    text-align: center;
    speak: none;
}

/* Keep the close mark visible even when a theme/plugin applies generic SVG/icon rules. */
.apg-close-button::after {
    content: none !important;
}

/* ---------- Image viewer ---------- */
.apg-content {
    max-height: calc(94vh - 77px);
    overflow: auto;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 15% 10%, rgba(255,255,255,.72), transparent 28%),
        var(--apg-surface-warm);
    scrollbar-width: thin;
    scrollbar-color: rgba(70,64,54,.25) transparent;
}

.apg-content::-webkit-scrollbar { width: 7px; }
.apg-content::-webkit-scrollbar-thumb {
    background: rgba(70,64,54,.22);
    border-radius: 20px;
}

.apg-viewport {
    width: 100%;
    padding: 22px;
}

.apg-track {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.apg-track.apg-count-1 {
    grid-template-columns: minmax(0, 1fr);
    max-width: 940px;
    margin-inline: auto;
}

.apg-slide {
    min-width: 0;
    margin: 0;
    padding: 7px;
    border: 1px solid rgba(50,45,38,.08);
    border-radius: var(--apg-radius-md);
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 30px rgba(38, 33, 27, .07);
}

.apg-image {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    border-radius: 12px;
    user-select: none;
    -webkit-user-drag: none;
}

.apg-mobile-controls { display: none; }

html.apg-lock,
body.apg-lock {
    overflow: hidden !important;
    overscroll-behavior: none;
}

/* ---------- Order panel ---------- */
.apg-order-panel {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: none;
    background:
        linear-gradient(135deg, rgba(250,248,243,.98), rgba(255,255,255,.99));
    overflow: auto;
    overscroll-behavior: contain;
}

.apg-order-panel.is-open {
    display: block;
    animation: apg-panel-in .20s ease both;
}

.apg-order-panel-inner {
    width: min(760px, calc(100% - 40px));
    margin: 0 auto;
    padding: 38px 0 48px;
}

.apg-order-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 22px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--apg-border);
}

.apg-order-panel-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 0 0 auto;
}

.apg-order-close-button {
    width: 40px;
    height: 40px;
}

.apg-order-close-button .apg-close-glyph {
    font-size: 27px;
    line-height: 36px;
}

.apg-order-panel-header h3,
.apg-success h3 {
    margin: 0 0 6px;
    color: var(--apg-title);
    font: inherit;
    font-size: 23px;
    line-height: 1.5;
    font-weight: 700;
    letter-spacing: -.02em;
}

.apg-order-panel-header p,
.apg-success p,
.apg-form-help {
    margin: 0;
    color: var(--apg-muted);
    line-height: 1.8;
}

.apg-order-back {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--apg-border-strong);
    border-radius: 999px;
    background: rgba(255,255,255,.78);
    color: var(--apg-title);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: border-color .18s ease, background .18s ease;
}

.apg-order-back:hover {
    background: #fff;
    border-color: rgba(45,41,34,.28);
}

.apg-order-form {
    padding: 24px;
    border: 1px solid var(--apg-border);
    border-radius: var(--apg-radius-lg);
    background: rgba(255,255,255,.82);
    box-shadow: 0 16px 55px rgba(37,32,25,.06);
}

.apg-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 16px;
}

.apg-field { display: block; }

.apg-field > span {
    display: block;
    margin-bottom: 8px;
    color: var(--apg-title);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.6;
}

.apg-field > span b {
    color: var(--apg-danger);
    font-weight: 700;
}

.apg-field input,
.apg-field textarea {
    width: 100%;
    border: 1px solid rgba(45,41,34,.13);
    border-radius: 14px;
    background: #fff;
    color: var(--apg-title);
    font: inherit;
    font-size: 14px;
    padding: 11px 13px;
    box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.apg-field input::placeholder,
.apg-field textarea::placeholder { color: #aaa49b; }

.apg-field input { min-height: 48px; }
.apg-field textarea {
    min-height: 116px;
    resize: vertical;
    line-height: 1.8;
}

.apg-field input:hover,
.apg-field textarea:hover {
    border-color: rgba(45,41,34,.22);
}

.apg-field input:focus,
.apg-field textarea:focus {
    outline: none;
    border-color: var(--apg-accent);
    box-shadow: 0 0 0 3px rgba(105, 88, 60, .09);
    background: #fff;
}

.apg-field-full { margin-top: 16px; }

.apg-submit-button {
    width: 100%;
    min-height: 52px;
    margin-top: 18px;
    border: 1px solid var(--apg-accent);
    border-radius: 999px;
    background: var(--apg-accent);
    color: #fff;
    font-weight: 700;
    padding: 12px 20px;
    box-shadow: 0 10px 30px rgba(38,33,27,.09);
    transition: opacity .18s ease, transform .18s ease, box-shadow .18s ease;
}

.apg-submit-button[disabled] {
    opacity: .58;
    cursor: wait;
    transform: none;
}

.apg-form-message {
    min-height: 0;
    margin-top: 14px;
    font-size: 13px;
    line-height: 1.8;
}

.apg-form-message.is-error {
    padding: 11px 13px;
    border: 1px solid rgba(164,61,53,.12);
    border-radius: 12px;
    background: #fff6f4;
    color: var(--apg-danger);
}

.apg-form-help {
    margin-top: 11px;
    text-align: center;
    font-size: 12px;
}

.apg-honeypot {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.apg-success {
    max-width: 580px;
    margin: 0 auto;
    text-align: center;
    padding: 72px 24px;
    border: 1px solid var(--apg-border);
    border-radius: var(--apg-radius-lg);
    background: rgba(255,255,255,.82);
    box-shadow: 0 16px 55px rgba(37,32,25,.06);
}

.apg-success-icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(62,117,80,.12);
    border-radius: 50%;
    background: #f0f7f2;
    color: var(--apg-success);
    font-size: 30px;
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(62,117,80,.08);
}

.apg-success p {
    max-width: 460px;
    margin-inline: auto;
}

.apg-success .apg-submit-button {
    width: auto;
    min-width: 180px;
    margin-top: 22px;
}

/* ---------- Product-card / archive CTA ---------- */
.apg-archive-trigger {
    position: relative;
    min-height: 40px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--wd-primary-color, #9b8562) !important;
    border-radius: 999px !important;
    padding-inline: 16px !important;
    background: transparent !important;
    color: var(--wd-primary-color, #9b8562) !important;
    box-shadow: none !important;
    cursor: pointer;
    font-weight: 600 !important;
    text-transform: none !important;
    transition: background .2s ease, color .2s ease, transform .2s ease, opacity .2s ease !important;
}

.apg-archive-trigger:hover {
    background: var(--wd-primary-color, #9b8562) !important;
    color: #fff !important;
    transform: translateY(-1px);
}

.apg-archive-trigger.is-loading {
    pointer-events: none;
    opacity: .72;
}

.apg-archive-trigger.is-loading > span { opacity: .18; }

.apg-archive-trigger.is-loading::after {
    content: "";
    position: absolute;
    inset-inline-start: 50%;
    top: 50%;
    width: 17px;
    height: 17px;
    margin: -8.5px 0 0 -8.5px;
    border: 1.8px solid currentColor;
    border-inline-start-color: transparent;
    border-radius: 50%;
    animation: apg-spin .65s linear infinite;
}

.apg-shortcode-loop-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.apg-ajax-root {
    width: 0;
    height: 0;
    overflow: visible;
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
    .apg-open-button {
        min-height: 52px;
        padding-inline: 18px;
    }

    .apg-modal {
        padding: 0;
        align-items: stretch;
    }

    .apg-dialog {
        width: 100vw;
        max-height: 100dvh;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        animation: apg-mobile-in .24s cubic-bezier(.2,.75,.25,1) both;
    }

    .apg-header {
        min-height: 66px;
        padding: 10px 12px;
        position: sticky;
        top: 0;
        z-index: 4;
        gap: 8px;
        box-shadow: 0 1px 0 var(--apg-border);
    }

    .apg-heading-wrap {
        flex: 1 1 auto;
        gap: 8px;
        min-width: 0;
    }

    .apg-title {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .apg-counter-mobile {
        display: block;
        padding: 2px 7px;
        border-radius: 999px;
        background: var(--apg-surface-warm);
    }

    .apg-header-actions { gap: 6px; }

    .apg-order-trigger {
        min-height: 38px;
        padding: 7px 10px;
        font-size: 11px;
    }

    .apg-close-button {
        width: 38px;
        height: 38px;
    }

    .apg-close-glyph {
        font-size: 27px;
        line-height: 34px;
    }

    .apg-content {
        flex: 1 1 auto;
        max-height: none;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 76px;
    }

    .apg-viewport {
        overflow: hidden;
        padding: 10px;
        touch-action: pan-y pinch-zoom;
    }

    .apg-track,
    .apg-track.apg-count-1 {
        display: flex;
        gap: 0;
        max-width: none;
        margin: 0;
        direction: ltr;
        transform: translate3d(0,0,0);
        transition: transform .28s cubic-bezier(.2,.75,.25,1);
        will-change: transform;
        align-items: flex-start;
    }

    .apg-slide {
        flex: 0 0 100%;
        width: 100%;
        direction: rtl;
        padding: 4px;
        border-radius: 14px;
        box-shadow: 0 6px 22px rgba(38,33,27,.05);
    }

    .apg-image { border-radius: 10px; }

    .apg-mobile-controls {
        direction: ltr;
        position: fixed;
        z-index: 5;
        left: 50%;
        bottom: max(12px, env(safe-area-inset-bottom));
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 6px 9px;
        border: 1px solid rgba(45,41,34,.10);
        border-radius: 999px;
        background: rgba(255,255,255,.94);
        box-shadow: 0 10px 34px rgba(30,26,21,.14);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .apg-nav-button {
        width: 40px;
        height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: var(--apg-surface-warm);
        color: var(--apg-title);
    }

    .apg-nav-button[disabled] {
        opacity: .25;
        cursor: default;
    }

    .apg-nav-button svg {
        width: 21px;
        height: 21px;
        fill: currentColor;
    }

    .apg-dots {
        display: flex;
        direction: ltr;
        gap: 6px;
        align-items: center;
    }

    .apg-dot {
        width: 6px;
        height: 6px;
        border-radius: 99px;
        background: rgba(45,41,34,.20);
        transition: width .2s ease, background .2s ease;
    }

    .apg-dot.is-active {
        width: 18px;
        background: var(--apg-accent);
    }

    .apg-order-panel-inner {
        width: 100%;
        min-height: 100%;
        padding: 18px 14px 32px;
    }

    .apg-order-panel-header {
        align-items: center;
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    .apg-order-panel-header h3 { font-size: 18px; }
    .apg-order-panel-header p {
        font-size: 12px;
        white-space: nowrap;
        max-width: 185px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .apg-order-back {
        padding: 7px 10px;
        font-size: 11px;
    }

    .apg-order-panel-actions {
        gap: 6px;
    }

    .apg-order-close-button {
        width: 38px;
        height: 38px;
    }

    .apg-order-form {
        padding: 16px;
        border-radius: 20px;
    }

    .apg-form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .apg-field-full { margin-top: 12px; }

    .apg-field input { min-height: 47px; }

    .apg-submit-button {
        min-height: 52px;
        position: sticky;
        bottom: max(8px, env(safe-area-inset-bottom));
        z-index: 2;
    }

    .apg-success {
        padding: 52px 18px;
        border-radius: 20px;
    }

    .apg-success .apg-submit-button {
        position: static;
    }

    .apg-archive-trigger {
        min-height: 38px;
        padding-inline: 13px !important;
        font-size: 12px !important;
    }
}

@media (min-width: 768px) and (max-width: 1100px) {
    .apg-dialog { width: min(1180px, 97vw); }
    .apg-viewport { padding: 16px; }
    .apg-track { gap: 12px; }
}

/* ---------- Motion ---------- */
@keyframes apg-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes apg-dialog-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes apg-mobile-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes apg-panel-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@media (prefers-reduced-motion: reduce) {
    .apg-modal.is-open,
    .apg-dialog,
    .apg-order-panel.is-open,
    .apg-track,
    .apg-open-button,
    .apg-order-trigger,
    .apg-submit-button,
    .apg-archive-trigger,
    .apg-archive-trigger.is-loading::after {
        animation: none !important;
        transition: none !important;
    }
}
