/* ==========================================================================
   JDM Stuff — Subscriptions Front-end
   Modal popup, Subscribe button, URL copy row, form feedback.
   Dark mode: html[data-theme="dark"]
   ========================================================================== */

/* ── Subscribe button ─────────────────────────────────────────────────────── */

.jdm-sub-subscribe-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    background: #c0392b;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, transform 0.1s;
    vertical-align: middle;
}

.jdm-sub-subscribe-btn:hover {
    background: #a93226;
}

.jdm-sub-subscribe-btn:active {
    transform: scale(0.97);
}

/* Dealer save-search button (mirrors wholesale style) */
.jdm-sub-save-btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    vertical-align: middle;
    opacity: 0.75;
}

.jdm-sub-save-btn:hover {
    opacity: 1;
}

/* Clipboard feedback under dealer search actions */
.jdm-sub-copy-feedback {
    font-size: 0.82em;
    color: #646970;
    margin-top: 4px;
    display: none;
}

/* ── Modal overlay ────────────────────────────────────────────────────────── */

.jdm-sub-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99998;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.jdm-sub-overlay.is-open {
    display: block;
    animation: jdmSubFadeIn 0.18s ease;
}

/* Prevent body scroll when modal is open */
body.jdm-sub-modal-open {
    overflow: hidden;
}

/* ── Modal panel ──────────────────────────────────────────────────────────── */

.jdm-sub-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -48%);
    width: min(480px, calc(100vw - 32px));
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 99999;
    padding: 32px 28px 28px;
    box-sizing: border-box;
}

.jdm-sub-modal.is-open {
    display: block;
    animation: jdmSubSlideIn 0.2s ease;
}

@keyframes jdmSubFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

/* ── Close button ─────────────────────────────────────────────────────────── */

.jdm-sub-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #646970;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    padding: 0;
}

.jdm-sub-modal-close:hover {
    background: #f0f0f0;
    color: #1d2327;
}

/* ── Modal content ────────────────────────────────────────────────────────── */

.jdm-sub-modal-source {
    display: inline-block;
    padding: 2px 8px;
    background: #c0392b;
    color: #fff;
    border-radius: 3px;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.jdm-sub-modal-title {
    margin: 0 0 6px;
    font-size: 1.2em;
    font-weight: 700;
    color: #1d2327;
    line-height: 1.25;
}

.jdm-sub-modal-desc {
    margin: 0 0 20px;
    font-size: 0.88em;
    color: #646970;
    line-height: 1.5;
}

/* ── Search URL row ───────────────────────────────────────────────────────── */

.jdm-sub-label {
    display: block;
    font-size: 0.78em;
    font-weight: 600;
    color: #3c434a;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.jdm-sub-url-row {
    margin-bottom: 18px;
}

.jdm-sub-url-wrap {
    display: flex;
    gap: 0;
    border: 1px solid #dcdcde;
    border-radius: 5px;
    overflow: hidden;
}

.jdm-sub-url-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: none;
    background: #f6f7f7;
    font-size: 0.8em;
    color: #646970;
    font-family: "Courier New", Courier, monospace;
    outline: none;
}

.jdm-sub-copy-url-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 12px;
    background: #f0f0f0;
    border: none;
    border-left: 1px solid #dcdcde;
    color: #3c434a;
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
}

.jdm-sub-copy-url-btn:hover {
    background: #e2e4e7;
}

/* ── Divider ──────────────────────────────────────────────────────────────── */

.jdm-sub-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0;
    color: #a7aaad;
    font-size: 0.8em;
}

.jdm-sub-divider::before,
.jdm-sub-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e4e7;
}

/* ── Email form ───────────────────────────────────────────────────────────── */

.jdm-sub-form-wrap {
    /* container */
}

.jdm-sub-email-row {
    display: flex;
    gap: 0;
    border: 1px solid #dcdcde;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
    transition: border-color 0.15s;
}

.jdm-sub-email-row:focus-within {
    border-color: #c0392b;
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.15);
}

.jdm-sub-email-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: none;
    background: #fff;
    font-size: 0.92em;
    color: #1d2327;
    outline: none;
}

.jdm-sub-email-input::placeholder {
    color: #a7aaad;
}

.jdm-sub-submit-btn {
    padding: 0 18px;
    background: #c0392b;
    color: #fff;
    border: none;
    font-size: 0.88em;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.jdm-sub-submit-btn:hover:not(:disabled) {
    background: #a93226;
}

.jdm-sub-submit-btn:disabled {
    opacity: 0.65;
    cursor: default;
}

.jdm-sub-consent-note {
    margin: 0 0 10px;
    font-size: 0.78em;
    color: #a7aaad;
    line-height: 1.5;
}

/* ── Form message (success / error) ──────────────────────────────────────── */

.jdm-sub-form-msg {
    display: none;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 0.85em;
    line-height: 1.5;
}

.jdm-sub-form-msg--success {
    background: #edfaef;
    color: #00a32a;
    border: 1px solid #b8e6bf;
}

.jdm-sub-form-msg--error {
    background: #fcecec;
    color: #b32d2e;
    border: 1px solid #f5c0c0;
}

/* ── Dark mode ────────────────────────────────────────────────────────────── */

html[data-theme="dark"] .jdm-sub-modal {
    background: #1e2227;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .jdm-sub-modal-title {
    color: #f0f0f0;
}

html[data-theme="dark"] .jdm-sub-modal-desc {
    color: #a7aaad;
}

html[data-theme="dark"] .jdm-sub-modal-close {
    color: #a7aaad;
}

html[data-theme="dark"] .jdm-sub-modal-close:hover {
    background: #2d3339;
    color: #f0f0f0;
}

html[data-theme="dark"] .jdm-sub-label {
    color: #a7aaad;
}

html[data-theme="dark"] .jdm-sub-url-input {
    background: #2d3339;
    color: #a7aaad;
    border-color: #3c434a;
}

html[data-theme="dark"] .jdm-sub-url-wrap {
    border-color: #3c434a;
}

html[data-theme="dark"] .jdm-sub-copy-url-btn {
    background: #2d3339;
    color: #c7c7c7;
    border-left-color: #3c434a;
}

html[data-theme="dark"] .jdm-sub-copy-url-btn:hover {
    background: #383f47;
}

html[data-theme="dark"] .jdm-sub-divider {
    color: #646970;
}

html[data-theme="dark"] .jdm-sub-divider::before,
html[data-theme="dark"] .jdm-sub-divider::after {
    background: #3c434a;
}

html[data-theme="dark"] .jdm-sub-email-row {
    border-color: #3c434a;
}

html[data-theme="dark"] .jdm-sub-email-input {
    background: #2d3339;
    color: #f0f0f0;
}

html[data-theme="dark"] .jdm-sub-email-input::placeholder {
    color: #646970;
}

html[data-theme="dark"] .jdm-sub-consent-note {
    color: #646970;
}

html[data-theme="dark"] .jdm-sub-form-msg--success {
    background: #0d2b12;
    color: #4caf67;
    border-color: #1a4d25;
}

html[data-theme="dark"] .jdm-sub-form-msg--error {
    background: #2b0d0d;
    color: #e57373;
    border-color: #4d1a1a;
}

html[data-theme="dark"] .jdm-sub-save-btn {
    color: #c7c7c7;
    border-color: #646970;
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .jdm-sub-overlay.is-open,
    .jdm-sub-modal.is-open {
        animation: none;
    }
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .jdm-sub-modal {
        padding: 24px 18px 20px;
        border-radius: 10px 10px 0 0;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        transform: none;
    }

    .jdm-sub-modal.is-open {
        animation: jdmSubSlideUp 0.22s ease;
    }

    @keyframes jdmSubSlideUp {
        from { opacity: 0; transform: translateY(30px); }
        to   { opacity: 1; transform: translateY(0); }
    }
}
