/**
 * Push Notification Widget Styles
 * Floating bell icon with tooltip and multi-step modal
 */

/* ===== Floating Widget ===== */
.push-widget {
    position: fixed;
    bottom: 100px; /* Above Journey bottom adhesion ad (~90px tall) */
    right: 80px;
    z-index: 9990;
    font-family: system-ui, -apple-system, sans-serif;
}

.push-widget-btn {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--bg-secondary, #1e293b) 0%, var(--bg-primary, #0f172a) 100%);
    color: white;
    font-size: 0;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    line-height: 0;
}

.push-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(14, 165, 233, 0.5);
}

.push-widget-btn:active {
    transform: scale(0.95);
}

/* Icon States */
.push-icon {
    position: absolute;
    transition: all 0.3s ease;
    width: 24px;
    height: 24px;
    color: white;
    pointer-events: none;
    display: block !important;
    visibility: visible !important;
    opacity: 1;
}

.push-icon-off { opacity: 1; transform: scale(1); }
.push-icon-on  { opacity: 0; transform: scale(0.5); }

/* Subscribed State */
.push-widget-btn.subscribed {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.push-widget-btn.subscribed .push-icon-off { opacity: 0; transform: scale(0.5); }
.push-widget-btn.subscribed .push-icon-on  { opacity: 1; transform: scale(1); animation: bellRing 0.5s ease; color: white; }

@keyframes bellRing {
    0%, 100% { transform: scale(1) rotate(0deg); }
    20% { transform: scale(1.1) rotate(15deg); }
    40% { transform: scale(1.1) rotate(-15deg); }
    60% { transform: scale(1.1) rotate(10deg); }
    80% { transform: scale(1.1) rotate(-10deg); }
}

/* Pulse */
.push-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(14, 165, 233, 0.4);
    animation: pushPulse 2s ease-out 1 forwards;
    pointer-events: none;
}

.push-widget-btn.subscribed .push-pulse { display: none; }

@keyframes pushPulse {
    0%   { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* Loading State */
.push-widget-btn.loading { pointer-events: none; }
.push-widget-btn.loading .push-icon { opacity: 0; }
.push-widget-btn.loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: pushSpin 0.8s linear infinite;
}

@keyframes pushSpin { to { transform: rotate(360deg); } }

/* First-time attention */
.push-widget:not(.interacted) .push-widget-btn:not(.subscribed) {
    animation: pushAttention 3s ease-in-out 2s;
}

@keyframes pushAttention {
    0%, 100% { transform: scale(1); }
    10%, 30%, 50% { transform: scale(1.15); }
    20%, 40% { transform: scale(1.05); }
}

/* Hide if unsupported */
.push-widget.unsupported { display: none; }

/* ===== Tooltip ===== */
.push-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.push-widget:hover .push-tooltip,
.push-widget:focus-within .push-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.push-tooltip-content {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-subtle, #334155);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.push-tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: #f1f5f9;
    font-size: 15px;
}

.push-tooltip-icon { width: 20px; height: 20px; flex-shrink: 0; color: #f1f5f9; }
.push-tooltip-text { color: #94a3b8; font-size: var(--text-sm); line-height: 1.5; margin: 0 0 12px; }

.push-tooltip-status {
    padding: 8px 12px;
    background: var(--bg-primary, #0f172a);
    border-radius: 8px;
    font-size: var(--text-sm);
    font-weight: 500;
    text-align: center;
}

.push-tooltip-status .status-off { color: #0ea5e9; display: block; }
.push-tooltip-status .status-on  { color: #10b981; display: none; }
.push-widget-btn.subscribed ~ .push-tooltip .status-off { display: none; }
.push-widget-btn.subscribed ~ .push-tooltip .status-on  { display: block; }

.push-tooltip-note { margin-top: 10px; text-align: center; }
.push-tooltip-note small { color: #64748b; font-size: 11px; }

.push-tooltip-arrow {
    position: absolute;
    bottom: -6px;
    right: 22px;
    width: 12px;
    height: 12px;
    background: var(--bg-secondary, #1e293b);
    border-right: 1px solid var(--border-subtle, #334155);
    border-bottom: 1px solid var(--border-subtle, #334155);
    transform: rotate(45deg);
}

/* ===== Multi-Step Modal ===== */
.push-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000; /* Modal above widget (9990) and ads */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.push-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.push-modal__content {
    position: relative;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-subtle, #334155);
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.push-modal__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle, #334155);
}

.push-modal__header svg { width: 32px; height: 32px; color: #10b981; flex-shrink: 0; }
.push-modal__header h3  { margin: 0; flex: 1; font-size: 1.25rem; color: #f1f5f9; }

.push-modal__close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.push-modal__close:hover { background: var(--border-subtle, #334155); color: #f1f5f9; }

.push-modal__body { padding: 1.5rem; }

/* Steps */
.push-modal__step {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.push-modal__step:last-child { margin-bottom: 0; }

.push-modal__step-num {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.push-modal__step-num--success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    font-size: 1.5rem;
}

.push-modal__step-body h4 { margin: 0 0 0.5rem; color: #f1f5f9; font-size: 1rem; }
.push-modal__step-body p  { margin: 0; color: #94a3b8; font-size: 0.875rem; line-height: 1.5; }

.push-modal__hint {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-primary, #0f172a);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.813rem;
    color: #cbd5e1;
}

.push-modal__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(16, 185, 129, 0.2);
    border-top-color: #10b981;
    border-radius: 50%;
    animation: pushSpin 0.8s linear infinite;
    margin: 1rem auto;
}

/* Error */
.push-modal__error {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    margin-top: 1rem;
}

.push-modal__error-icon { font-size: 2rem; flex-shrink: 0; }
.push-modal__error-body h4 { margin: 0 0 0.5rem; color: #ef4444; font-size: 1rem; }
.push-modal__error-body p  { margin: 0; color: #fca5a5; font-size: 0.875rem; }

/* Note box */
.push-modal__note {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    margin: 0.75rem 0;
    font-size: 0.8rem;
    color: #93c5fd;
}

.push-modal__note strong { color: #60a5fa; }
.push-modal__note ul { margin: 0.4rem 0 0; padding-left: 1.25rem; line-height: 1.5; }

/* Scroll hint */
.push-modal__scroll-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #22c55e;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(34, 197, 94, 0.12);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1.5px solid rgba(34, 197, 94, 0.4);
    margin-bottom: 0.75rem;
    animation: pushGlow 2s ease-in-out infinite;
}

.push-modal__scroll-hint svg { flex-shrink: 0; animation: pushBounce 1s ease-in-out infinite; }

@keyframes pushGlow {
    0%, 100% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); border-color: rgba(34, 197, 94, 0.5); }
    50% { box-shadow: 0 2px 12px rgba(34, 197, 94, 0.4); border-color: rgba(34, 197, 94, 0.8); }
}

@keyframes pushBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

/* Footer */
.push-modal__footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-subtle, #334155);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.push-modal__btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.push-modal__btn--primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.push-modal__btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.push-modal__btn--secondary {
    background: var(--border-subtle, #334155);
    color: #f1f5f9;
}

.push-modal__btn--secondary:hover { background: #475569; }

/* ===== Preference Sections ===== */
.push-prefs {
    margin-top: 0.75rem;
    max-height: 50vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.6) rgba(30, 41, 59, 0.5);
}

.push-prefs::-webkit-scrollbar { width: 8px; }
.push-prefs::-webkit-scrollbar-track { background: rgba(30, 41, 59, 0.5); border-radius: 4px; }
.push-prefs::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.6); border-radius: 4px; }
.push-prefs::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.8); }

.push-prefs__section {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-primary, #0f172a);
    border-radius: 8px;
    border: 1px solid var(--border-subtle, #334155);
    transition: opacity 0.2s ease;
}

.push-prefs__section-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle, #334155);
}

.push-prefs__section-header strong { display: block; color: #f1f5f9; font-size: var(--text-base); margin-bottom: 0.25rem; }
.push-prefs__section-header small  { display: block; color: #94a3b8; font-size: 0.813rem; }

.push-prefs__group {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-primary, #0f172a);
    border-radius: 8px;
    border: 1px solid var(--border-subtle, #334155);
}

.push-prefs__label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.push-prefs__label input[type="checkbox"] {
    margin-top: 0.125rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #10b981;
    flex-shrink: 0;
}

.push-prefs__text { flex: 1; }
.push-prefs__text strong { display: block; color: #f1f5f9; font-size: var(--text-base); margin-bottom: 0.25rem; }
.push-prefs__text small  { display: block; color: #94a3b8; font-size: 0.813rem; line-height: 1.4; }

/* Grid for compact items (priorities, regions, categories) */
.push-prefs__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.push-prefs__grid--scrollable {
    max-height: 300px;
    overflow-y: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.6) rgba(30, 41, 59, 0.5);
}

.push-prefs__grid--scrollable::-webkit-scrollbar { width: 8px; }
.push-prefs__grid--scrollable::-webkit-scrollbar-track { background: rgba(30, 41, 59, 0.5); border-radius: 4px; }
.push-prefs__grid--scrollable::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.6); border-radius: 4px; }

.push-prefs__grid-item {
    background: var(--bg-secondary, #1e293b);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.push-prefs__grid-item:hover { border-color: #475569; }
.push-prefs__grid-item:has(input:checked) { background: rgba(16, 185, 129, 0.15); border-color: #10b981; }

.push-prefs__label-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.813rem;
    color: #cbd5e1;
    margin: 0;
}

.push-prefs__label-compact input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #10b981;
    flex-shrink: 0;
}

.push-prefs__label-compact input[type="checkbox"]:disabled { opacity: 0.5; cursor: not-allowed; }
.push-prefs__label-compact span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.push-prefs__separator {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border-subtle, #334155);
    margin: 0.5rem 0;
    padding-top: 0.5rem;
}

.push-prefs__separator small { color: #64748b; font-size: 0.75rem; }

.push-prefs__loading,
.push-prefs__empty {
    grid-column: 1 / -1;
    color: #64748b;
    font-size: 0.813rem;
    padding: 0.5rem;
    text-align: center;
}

.push-prefs__empty { font-style: italic; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .push-prefs__grid { grid-template-columns: repeat(3, 1fr); gap: 0.375rem; }
    .push-prefs__section { padding: 0.75rem; }
    .push-prefs__grid-item { padding: 0.375rem 0.5rem; }
    .push-prefs__grid--scrollable { max-height: 220px; }

    .push-prefs__label-compact {
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
    }

    .push-prefs__label-compact input[type="checkbox"] { margin: 0 auto; }
}

@media (max-width: 480px) {
    .push-widget { bottom: 100px; right: 16px; }
    .push-widget-btn { width: 50px; height: 50px; }
    .push-tooltip { width: 260px; right: -8px; }
    .push-tooltip-content { padding: 12px; }

    .push-modal__content { max-width: 100%; border-radius: 12px; }
    .push-modal__header,
    .push-modal__body,
    .push-modal__footer { padding: 1rem; }

    .push-prefs__grid { grid-template-columns: repeat(2, 1fr); gap: 0.25rem; }
    .push-prefs__grid-item { padding: 0.25rem 0.375rem; }
    .push-prefs__label-compact { font-size: 0.6875rem; }
}
