/* ================================================================
   CUSTOM POPUP — Light & Dark Mode Adaptive
   ================================================================ */

/* ---------- Shared overlay ---------- */
.custom-popup-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(4, 7, 13, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

.custom-popup-overlay.active { opacity: 1; }

/* ---------- Popup box — DARK MODE (default) ---------- */
.custom-popup-box {
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    width: 100%;
    max-width: 460px;
    padding: 28px;
    box-shadow:
        0 30px 60px -12px rgba(0, 0, 0, 0.7),
        0 0 1px 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    color: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transform: scale(0.92) translateY(12px);
    transition: transform 0.24s cubic-bezier(0.34, 1.3, 0.64, 1);
    box-sizing: border-box;
}

.custom-popup-overlay.active .custom-popup-box {
    transform: scale(1) translateY(0);
}

/* ---------- Popup box — LIGHT MODE ---------- */
body.light-mode .custom-popup-box,
html.light-mode .custom-popup-box {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow:
        0 30px 60px -12px rgba(0, 0, 0, 0.12),
        0 8px 24px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    color: #0f172a;
}

/* ---------- Title ---------- */
.custom-popup-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0 0 14px 0;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

body.light-mode .custom-popup-title,
html.light-mode .custom-popup-title { color: #0f172a; }

/* ---------- Message body ---------- */
.custom-popup-message {
    font-size: 0.938rem;
    color: #94a3b8;
    line-height: 1.6;
    margin: 0 0 24px 0;
    white-space: pre-wrap;
    word-break: break-word;
}

body.light-mode .custom-popup-message,
html.light-mode .custom-popup-message { color: #475569; }

/* ---------- Actions row ---------- */
.custom-popup-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* ---------- Buttons ---------- */
.custom-popup-btn {
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 9px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    outline: none;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

/* Primary */
.custom-popup-btn-primary {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.custom-popup-btn-primary:hover {
    background: linear-gradient(135deg, #059669, #047857);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45);
    transform: translateY(-1px);
}
.custom-popup-btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

/* Secondary — DARK */
.custom-popup-btn-secondary {
    background: rgba(255, 255, 255, 0.07);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.custom-popup-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.13);
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.2);
}
.custom-popup-btn-secondary:active { background: rgba(255, 255, 255, 0.08); }

/* Secondary — LIGHT */
body.light-mode .custom-popup-btn-secondary,
html.light-mode .custom-popup-btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}
body.light-mode .custom-popup-btn-secondary:hover,
html.light-mode .custom-popup-btn-secondary:hover {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #cbd5e1;
}

/* Focus ring */
.custom-popup-btn:focus-visible {
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #10b981;
}
body.light-mode .custom-popup-btn:focus-visible,
html.light-mode .custom-popup-btn:focus-visible {
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #059669;
}

/* Overlay backdrop — lighter in light mode */
body.light-mode .custom-popup-overlay,
html.light-mode .custom-popup-overlay {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ---------- Clear Chat Choice Modal (Compact WhatsApp Style) ---------- */
.custom-clear-chat-box {
    max-width: 350px !important;
    width: 90% !important;
    padding: 18px 20px !important;
    border-radius: 14px !important;
}

.custom-clear-chat-box .custom-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-clear-chat-box .custom-clear-icon {
    font-size: 1.15rem;
    line-height: 1;
}

.custom-clear-chat-box .custom-popup-title {
    font-size: 1rem !important;
    font-weight: 700 !important;
    margin: 0 !important;
}

.custom-clear-chat-box .custom-popup-message {
    font-size: 0.83rem !important;
    line-height: 1.35 !important;
    margin: 4px 0 10px 0 !important;
}

.custom-choice-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0 12px 0;
}

.custom-choice-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: #e2e8f0;
    cursor: pointer;
    text-align: left;
    transition: all 0.18s ease;
    outline: none;
    user-select: none;
    font-family: inherit;
    width: 100%;
}

.custom-choice-btn:focus-visible {
    box-shadow: 0 0 0 2px #10b981;
}

.choice-icon-wrap {
    font-size: 1.05rem;
    width: 30px;
    height: 30px;
    min-width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
}

.choice-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.choice-title {
    font-size: 0.86rem;
    font-weight: 600;
    color: #f8fafc;
}

.choice-subtitle {
    font-size: 0.74rem;
    color: #94a3b8;
    line-height: 1.25;
}

/* Hover effects for choices */
.choice-for-me:hover {
    background: rgba(16, 185, 129, 0.08);
    border-color: #10b981;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
}

.choice-for-me:hover .choice-icon-wrap {
    background: rgba(16, 185, 129, 0.15);
}

.choice-for-both:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #ef4444;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.12);
}

.choice-for-both:hover .choice-icon-wrap {
    background: rgba(239, 68, 68, 0.15);
}

.choice-for-both .choice-title {
    color: #f87171;
}

/* Light mode overrides for choices */
body.light-mode .custom-choice-btn,
html.light-mode .custom-choice-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #1e293b;
}

body.light-mode .choice-title,
html.light-mode .choice-title {
    color: #0f172a;
}

body.light-mode .choice-subtitle,
html.light-mode .choice-subtitle {
    color: #64748b;
}

body.light-mode .choice-icon-wrap,
html.light-mode .choice-icon-wrap {
    background: #f1f5f9;
}

body.light-mode .choice-for-me:hover {
    background: #ecfdf5;
    border-color: #10b981;
}

body.light-mode .choice-for-both:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

body.light-mode .choice-for-both .choice-title {
    color: #dc2626;
}

.custom-choice-actions {
    margin-top: 6px;
    display: flex;
    justify-content: flex-end;
}

.custom-choice-actions .custom-popup-btn {
    padding: 6px 16px !important;
    font-size: 0.82rem !important;
    border-radius: 8px !important;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
    .custom-popup-box { padding: 18px; border-radius: 14px; }
    .custom-clear-chat-box { max-width: 320px !important; padding: 16px !important; }
    .custom-popup-btn { width: 100%; text-align: center; padding: 10px 14px; }
    .custom-popup-actions { flex-direction: column-reverse; }
    .custom-choice-btn { padding: 8px 10px; }
    .choice-icon-wrap { width: 28px; height: 28px; min-width: 28px; font-size: 0.95rem; }
}
