/* ==========================================================================
   IWT CRM — Popup Styles  v1.3.1
   Templates: classic · minimal · bold
   ========================================================================== */

/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
    --iwt-blue:       #0073aa;
    --iwt-blue-dk:    #005a87;
    --iwt-blue-lt:    #e8f4fb;
    --iwt-ink:        #0f172a;
    --iwt-ink-mid:    #475569;
    --iwt-ink-soft:   #94a3b8;
    --iwt-surface:    #ffffff;
    --iwt-muted:      #f1f5f9;
    --iwt-border:     #e2e8f0;
    --iwt-radius-lg:  20px;
    --iwt-radius-md:  12px;
    --iwt-radius-sm:  8px;
    --iwt-radius-pill:100px;
    --iwt-shadow-lg:  0 32px 80px rgba(15,23,42,.28), 0 8px 24px rgba(15,23,42,.12);
    --iwt-shadow-md:  0 16px 40px rgba(15,23,42,.18), 0 4px 12px rgba(15,23,42,.08);
    --iwt-ease:       cubic-bezier(.16,1,.3,1);
}

/* ── Overlay ───────────────────────────────────────────────────────────────── */
.iwt-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity .35s ease;
    /* Modern frosted-glass backdrop */
    background: rgba(15, 23, 42, .6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.iwt-popup-overlay.iwt-popup-visible {
    opacity: 1;
}

/* ── Shared box ────────────────────────────────────────────────────────────── */
.iwt-popup-box {
    position: relative;
    width: 100%;
    max-width: 480px;
    box-sizing: border-box;
    transform: translateY(32px) scale(.97);
    transition: transform .45s var(--iwt-ease), opacity .45s var(--iwt-ease);
    opacity: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.iwt-popup-visible .iwt-popup-box {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* ── Close button ──────────────────────────────────────────────────────────── */
.iwt-popup-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(148,163,184,.12);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: var(--iwt-ink-soft);
    padding: 0;
    z-index: 10;
    transition: background .2s, color .2s, transform .2s;
}
.iwt-popup-close:hover {
    background: rgba(148,163,184,.25);
    color: var(--iwt-ink);
    transform: rotate(90deg);
}

/* ── Typography ────────────────────────────────────────────────────────────── */
.iwt-popup-title {
    margin: 0 0 10px;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -.4px;
}
.iwt-popup-subtitle {
    margin: 0 0 22px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--iwt-ink-mid);
}

/* ── Inputs ────────────────────────────────────────────────────────────────── */
.iwt-popup-field { margin-bottom: 12px; }

.iwt-popup-input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--iwt-border);
    border-radius: var(--iwt-radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--iwt-muted);
    color: var(--iwt-ink);
    box-sizing: border-box;
    outline: none;
    transition: border-color .2s, background .2s, box-shadow .2s;
    -webkit-appearance: none;
}
.iwt-popup-input::placeholder { color: var(--iwt-ink-soft); }
.iwt-popup-input:focus {
    border-color: var(--iwt-blue);
    background: var(--iwt-surface);
    box-shadow: 0 0 0 4px rgba(0,115,170,.12);
}

/* ── Button ────────────────────────────────────────────────────────────────── */
.iwt-popup-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--iwt-radius-pill);
    font-size: 15px;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: .2px;
    cursor: pointer;
    transition: background .25s, box-shadow .25s, transform .15s;
    margin-top: 6px;
    position: relative;
    overflow: hidden;
}
/* Shimmer on hover */
.iwt-popup-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.18) 50%, transparent 60%);
    transform: translateX(-100%);
    transition: transform .5s ease;
}
.iwt-popup-btn:hover::after { transform: translateX(100%); }
.iwt-popup-btn:active  { transform: scale(.97); }
.iwt-popup-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ── Success / error message ───────────────────────────────────────────────── */
.iwt-popup-message {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: var(--iwt-radius-sm);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.iwt-popup-message.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.iwt-popup-message.success::before { content: '✓'; font-weight: 800; }
.iwt-popup-message.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.iwt-popup-message.error::before { content: '✕'; font-weight: 800; }

/* ── Privacy note (shared) ─────────────────────────────────────────────────── */
.iwt-popup-privacy {
    margin-top: 14px;
    font-size: 11px;
    color: var(--iwt-ink-soft);
    text-align: center;
    line-height: 1.5;
}
.iwt-popup-privacy a { color: var(--iwt-blue); text-decoration: none; }

/* ==========================================================================
   TEMPLATE 1 — Classic
   Clean white card · blue top accent · generous padding
   ========================================================================== */
.iwt-popup-tpl-classic .iwt-popup-box {
    background: var(--iwt-surface);
    border-radius: var(--iwt-radius-lg);
    padding: 44px 40px 36px;
    box-shadow: var(--iwt-shadow-lg);
    /* Coloured top bar via gradient border trick */
    border-top: 4px solid transparent;
    background-clip: padding-box;
    position: relative;
}
/* Gradient top accent line */
.iwt-popup-tpl-classic .iwt-popup-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    border-radius: var(--iwt-radius-lg) var(--iwt-radius-lg) 0 0;
    background: linear-gradient(90deg, #0073aa, #00a8d6, #0073aa);
    background-size: 200% 100%;
    animation: iwtShimmerBar 3s linear infinite;
}
@keyframes iwtShimmerBar {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.iwt-popup-tpl-classic .iwt-popup-title { color: var(--iwt-ink); }
.iwt-popup-tpl-classic .iwt-popup-subtitle { color: var(--iwt-ink-mid); }
.iwt-popup-tpl-classic .iwt-popup-input {
    border-color: var(--iwt-border);
    background: var(--iwt-muted);
}
.iwt-popup-tpl-classic .iwt-popup-btn {
    background: linear-gradient(135deg, #0073aa, #0091d4);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,115,170,.35);
}
.iwt-popup-tpl-classic .iwt-popup-btn:hover {
    background: linear-gradient(135deg, #005a87, #0073aa);
    box-shadow: 0 6px 20px rgba(0,115,170,.45);
}
.iwt-popup-tpl-classic .iwt-popup-close { color: var(--iwt-ink-soft); }

/* ==========================================================================
   TEMPLATE 2 — Minimal
   Almost borderless · soft shadow · dark pill button
   ========================================================================== */
.iwt-popup-tpl-minimal .iwt-popup-box {
    background: var(--iwt-surface);
    border-radius: var(--iwt-radius-lg);
    padding: 48px 40px 36px;
    box-shadow: var(--iwt-shadow-md);
    border: 1px solid rgba(226,232,240,.6);
}
.iwt-popup-tpl-minimal .iwt-popup-title {
    color: var(--iwt-ink);
    font-size: 22px;
}
.iwt-popup-tpl-minimal .iwt-popup-subtitle { color: #64748b; }
.iwt-popup-tpl-minimal .iwt-popup-input {
    border-color: var(--iwt-border);
    background: var(--iwt-muted);
    border-radius: var(--iwt-radius-sm);
}
.iwt-popup-tpl-minimal .iwt-popup-btn {
    background: var(--iwt-ink);
    color: #fff;
    border-radius: var(--iwt-radius-pill);
    box-shadow: 0 4px 14px rgba(15,23,42,.25);
}
.iwt-popup-tpl-minimal .iwt-popup-btn:hover {
    background: #1e293b;
    box-shadow: 0 6px 18px rgba(15,23,42,.35);
}
.iwt-popup-tpl-minimal .iwt-popup-close { color: var(--iwt-ink-soft); }

/* Divider line between content + form */
.iwt-popup-tpl-minimal .iwt-popup-divider {
    height: 1px;
    background: var(--iwt-border);
    margin: 0 0 20px;
}

/* ==========================================================================
   TEMPLATE 3 — Bold
   Full-bleed gradient header · icon badge · bright CTA
   ========================================================================== */
.iwt-popup-tpl-bold .iwt-popup-box {
    background: var(--iwt-surface);
    border-radius: var(--iwt-radius-lg);
    overflow: hidden;
    box-shadow: var(--iwt-shadow-lg);
    padding: 0;
}

.iwt-popup-tpl-bold .iwt-popup-bold-header {
    background: linear-gradient(140deg, #0055a4 0%, #0073aa 45%, #009fd4 100%);
    padding: 40px 36px 32px;
    position: relative;
    overflow: hidden;
}
/* Decorative circle blobs */
.iwt-popup-tpl-bold .iwt-popup-bold-header::before,
.iwt-popup-tpl-bold .iwt-popup-bold-header::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    opacity: .12;
    background: #fff;
}
.iwt-popup-tpl-bold .iwt-popup-bold-header::before {
    width: 220px; height: 220px;
    top: -60px; right: -60px;
}
.iwt-popup-tpl-bold .iwt-popup-bold-header::after {
    width: 140px; height: 140px;
    bottom: -50px; left: -30px;
}

/* Email icon badge */
.iwt-popup-tpl-bold .iwt-popup-icon {
    width: 52px;
    height: 52px;
    background: rgba(255,255,255,.18);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(4px);
}

.iwt-popup-tpl-bold .iwt-popup-bold-body {
    padding: 28px 36px 36px;
}

.iwt-popup-tpl-bold .iwt-popup-title {
    color: #fff;
    font-size: 26px;
    margin: 0;
    position: relative;
    z-index: 1;
}
.iwt-popup-tpl-bold .iwt-popup-subtitle {
    color: var(--iwt-ink-mid);
    margin-bottom: 20px;
}
.iwt-popup-tpl-bold .iwt-popup-close {
    color: rgba(255,255,255,.65);
    background: rgba(255,255,255,.12);
}
.iwt-popup-tpl-bold .iwt-popup-close:hover {
    background: rgba(255,255,255,.22);
    color: #fff;
    transform: rotate(90deg);
}
.iwt-popup-tpl-bold .iwt-popup-input {
    border-color: var(--iwt-border);
    background: var(--iwt-muted);
}
.iwt-popup-tpl-bold .iwt-popup-btn {
    background: linear-gradient(135deg, #0073aa, #0091d4);
    color: #fff;
    border-radius: var(--iwt-radius-pill);
    box-shadow: 0 4px 18px rgba(0,115,170,.4);
    padding: 15px 20px;
}
.iwt-popup-tpl-bold .iwt-popup-btn:hover {
    background: linear-gradient(135deg, #005a87, #0073aa);
    box-shadow: 0 6px 22px rgba(0,115,170,.5);
}

/* Subscriber count badge in bold header */
.iwt-popup-trust-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.15);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 100px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,.9);
    margin-top: 14px;
    position: relative;
    z-index: 1;
}
.iwt-popup-trust-badge::before {
    content: '👥';
    font-size: 13px;
}

/* ==========================================================================
   Mobile — slide-up sheet on ≤ 540px
   ========================================================================== */
@media (max-width: 540px) {
    .iwt-popup-overlay {
        padding: 0;
        align-items: flex-end;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    .iwt-popup-box {
        max-width: 100%;
        width: 100%;
        border-radius: 24px 24px 0 0 !important;
        transform: translateY(100%);
        transition: transform .4s var(--iwt-ease), opacity .4s var(--iwt-ease);
    }
    .iwt-popup-visible .iwt-popup-box {
        transform: translateY(0);
        opacity: 1;
    }
    /* Drag handle pill */
    .iwt-popup-box::after {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--iwt-border);
        border-radius: 99px;
        margin: 0 auto 16px;
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
    }
    .iwt-popup-tpl-classic .iwt-popup-box,
    .iwt-popup-tpl-minimal .iwt-popup-box { padding: 36px 24px 28px; }
    .iwt-popup-tpl-classic .iwt-popup-box::before { display: none; }
    .iwt-popup-tpl-bold .iwt-popup-bold-header { padding: 32px 24px 24px; }
    .iwt-popup-tpl-bold .iwt-popup-bold-body   { padding: 20px 24px 28px; }
    .iwt-popup-title    { font-size: 20px !important; letter-spacing: -.3px; }
    .iwt-popup-subtitle { font-size: 13px !important; }
    .iwt-popup-btn      { padding: 15px 20px !important; font-size: 16px !important; }
}

/* ==========================================================================
   Admin — Template Picker
   ========================================================================== */
.iwt-tpl-picker {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.iwt-tpl-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border: 2px solid var(--iwt-border, #e2e8f0);
    border-radius: 12px;
    padding: 14px 18px;
    min-width: 120px;
    transition: border-color .2s, background .2s, box-shadow .2s;
    background: #fff;
}
.iwt-tpl-option input[type=radio] { display: none; }
.iwt-tpl-option.active {
    border-color: #0073aa;
    background: #f0f7fb;
    box-shadow: 0 0 0 4px rgba(0,115,170,.1);
}
.iwt-tpl-option:hover:not(.active) {
    border-color: #94c8e0;
    background: #f8fbfd;
}
.iwt-tpl-option strong { font-size: 13px; color: #0f172a; }
.iwt-tpl-option small  { font-size: 11px; color: #64748b; text-align: center; line-height: 1.4; }

/* Mini thumbnail sketch */
.iwt-tpl-thumb {
    width: 88px;
    height: 62px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}
.iwt-tpl-thumb-classic { border-top: 3px solid #0073aa; }
.iwt-tpl-thumb-bold    { border: none; }
.iwt-tpl-thumb-bold .t-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 22px;
    background: linear-gradient(135deg,#0055a4,#009fd4);
}
.t-bar   { width: 88%; height: 3px; background: linear-gradient(90deg,#0073aa,#0091d4); border-radius: 99px; }
.t-line  { width: 78%; height: 4px; background: #e2e8f0; border-radius: 99px; }
.t-line.short { width: 52%; }
.t-input { width: 88%; height: 7px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 3px; }
.t-btn   { width: 66%; height: 8px; background: linear-gradient(90deg,#0073aa,#0091d4); border-radius: 99px; }
.t-btn-sm{ width: 52%; height: 7px; background: #0f172a; border-radius: 99px; }
.t-header{ width: 100%; height: 14px; background: linear-gradient(90deg,#0055a4,#009fd4); margin-top: 22px; }

/* ==========================================================================
   Admin — Static template showcase (list screen)
   ========================================================================== */
.iwt-popup-preview-static {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    pointer-events: none;
    user-select: none;
    transform: scale(.88);
    transform-origin: top center;
    margin-bottom: -12%;
}
.iwt-popup-preview-static .iwt-popup-box {
    box-shadow: 0 4px 16px rgba(0,0,0,.08) !important;
    transform: none !important;
    opacity: 1 !important;
}
.iwt-popup-preview-static .iwt-popup-box::before { animation: none !important; }
.iwt-popup-preview-static .iwt-popup-title    { font-size: 14px !important; }
.iwt-popup-preview-static .iwt-popup-subtitle { font-size: 11px !important; }
.iwt-popup-preview-static .iwt-popup-input    { font-size: 11px !important; padding: 6px 9px !important; }
.iwt-popup-preview-static .iwt-popup-btn      { font-size: 11px !important; padding: 7px 12px !important; }
.iwt-popup-preview-static .iwt-popup-icon     { width: 32px !important; height: 32px !important; font-size: 16px !important; }
.iwt-popup-preview-static .iwt-popup-trust-badge { font-size: 10px !important; padding: 3px 8px !important; }

/* ==========================================================================
   Admin — Live preview (edit screen)
   ========================================================================== */
.iwt-popup-preview-live {
    pointer-events: none;
    user-select: none;
}
.iwt-popup-preview-live .iwt-popup-box {
    box-shadow: 0 8px 28px rgba(0,0,0,.14) !important;
    transform: none !important;
    opacity: 1 !important;
    max-width: 100% !important;
}
.iwt-popup-preview-live .iwt-popup-box::before { animation: none !important; }
.iwt-popup-preview-live .iwt-popup-title    { font-size: 18px !important; }
.iwt-popup-preview-live .iwt-popup-subtitle { font-size: 12px !important; }
.iwt-popup-preview-live .iwt-popup-input    { font-size: 12px !important; padding: 9px 11px !important; }
.iwt-popup-preview-live .iwt-popup-btn      { font-size: 13px !important; padding: 10px 14px !important; }

/* ==========================================================================
   Popup — Checkbox items
   ========================================================================== */
.iwt-popup-cb-field { margin-bottom: 10px; }

.iwt-popup-cb-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--iwt-ink-mid, #475569);
    line-height: 1.5;
}
.iwt-popup-cb-row input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Custom box */
.iwt-popup-cb-custom {
    flex-shrink: 0;
    width: 17px;
    height: 17px;
    margin-top: 1px;
    border: 2px solid var(--iwt-border, #e2e8f0);
    border-radius: 4px;
    background: var(--iwt-muted, #f1f5f9);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .18s, background .18s, box-shadow .18s;
}
.iwt-popup-cb-custom::after {
    content: '';
    display: block;
    width: 9px;
    height: 6px;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 7' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 3.5l2.5 2.5 5.5-5' stroke='%23fff' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/cover no-repeat;
    opacity: 0;
    transform: scale(.5);
    transition: opacity .15s, transform .15s;
}

/* Checked */
.iwt-popup-cb-row input[type="checkbox"]:checked + .iwt-popup-cb-custom {
    background: var(--iwt-blue, #0073aa);
    border-color: var(--iwt-blue, #0073aa);
    box-shadow: 0 0 0 3px rgba(0,115,170,.15);
}
.iwt-popup-cb-row input[type="checkbox"]:checked + .iwt-popup-cb-custom::after {
    opacity: 1;
    transform: scale(1);
}

/* Hover */
.iwt-popup-cb-row:hover .iwt-popup-cb-custom {
    border-color: var(--iwt-blue, #0073aa);
}

.iwt-popup-cb-label { flex: 1; }
.iwt-popup-cb-req   { color: #e11d48; font-weight: 700; margin-left: 1px; }
