/**
 * Upgrade Limit Modal - Premium subscription upgrade prompt
 * Reusable across all limit-gated features
 */

/* ─── Variables - Light Mode (default) ─── */
.upgrade-modal {
    --upgrade-bg: rgba(15, 23, 42, 0.65);
    --upgrade-card-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.95));
    --upgrade-card-border: rgba(99, 102, 241, 0.2);
    --upgrade-text: #0f172a;
    --upgrade-text-muted: #64748b;
    --upgrade-glow: rgba(99, 102, 241, 0.35);
    --upgrade-gradient: linear-gradient(135deg, #6366f1, #a855f7, #0ea5e9);
    --upgrade-list-bg: rgba(0, 0, 0, 0.05);
    --upgrade-close-bg: rgba(99, 102, 241, 0.08);
    --upgrade-close-hover-bg: rgba(99, 102, 241, 0.15);
}

/* ─── Variables - Dark Mode ─── */
[data-bs-theme="dark"] .upgrade-modal,
.dark-style .upgrade-modal {
    --upgrade-bg: rgba(15, 23, 42, 0.88);
    --upgrade-card-bg: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(51, 65, 85, 0.95));
    --upgrade-card-border: rgba(99, 102, 241, 0.3);
    --upgrade-text: #f1f5f9;
    --upgrade-text-muted: #94a3b8;
    --upgrade-glow: rgba(99, 102, 241, 0.45);
    --upgrade-list-bg: rgba(0, 0, 0, 0.25);
    --upgrade-close-bg: rgba(99, 102, 241, 0.15);
    --upgrade-close-hover-bg: rgba(99, 102, 241, 0.25);
}

/* ─── Overlay ─── */
.upgrade-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--upgrade-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.upgrade-modal.is-open {
    display: flex;
}

/* ─── Container ─── */
.upgrade-modal__container {
    position: relative;
    width: min(480px, 100%);
    padding: 2rem;
    background: var(--upgrade-card-bg);
    border: 1px solid var(--upgrade-card-border);
    border-radius: 1.5rem;
    box-shadow: 
        0 0 0 1px rgba(99, 102, 241, 0.15),
        0 25px 60px -20px rgba(0, 0, 0, 0.55),
        0 0 80px -30px var(--upgrade-glow);
    text-align: center;
    animation: upgradeModalIn 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes upgradeModalIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ─── Close Button ─── */
.upgrade-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    background: var(--upgrade-close-bg);
    color: var(--upgrade-text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.upgrade-modal__close:hover {
    background: var(--upgrade-close-hover-bg);
    color: var(--upgrade-text);
    transform: rotate(90deg);
}

.upgrade-modal__close i {
    font-size: 1.25rem;
}

/* ─── Icon Container ─── */
.upgrade-modal__icon {
    width: 5rem;
    height: 5rem;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.12));
    border-radius: 50%;
    position: relative;
}

.upgrade-modal__icon::before {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--upgrade-gradient);
    opacity: 0.25;
    filter: blur(12px);
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(1.08); }
}

.upgrade-modal__icon i {
    font-size: 2.5rem;
    background: var(--upgrade-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    position: relative;
    z-index: 1;
}

/* ─── Content ─── */
.upgrade-modal__title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--upgrade-text);
    margin-bottom: 0.5rem;
    background: var(--upgrade-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.upgrade-modal__message {
    font-size: 0.95rem;
    color: var(--upgrade-text-muted);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.upgrade-modal__message strong {
    color: var(--upgrade-text);
    font-weight: 600;
}

.upgrade-modal__limit {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #818cf8;
    margin-bottom: 1.5rem;
}

.upgrade-modal__limit i {
    font-size: 0.9rem;
}

/* ─── Actions ─── */
.upgrade-modal__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* A link and a button side by side: the same box, so they line up. */
.upgrade-modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.25;
    border-radius: 0.85rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* The panel takes focus when the dialog opens; it needs no ring. */
.upgrade-modal__container:focus { outline: none; }

.upgrade-modal__close:focus:not(:focus-visible) { outline: none; box-shadow: none; }
.upgrade-modal__close:focus-visible,
.upgrade-modal__btn:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }

.upgrade-modal__btn--secondary {
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: var(--upgrade-text-muted);
}

.upgrade-modal__btn--secondary:hover {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.4);
    color: var(--upgrade-text);
}

/* !important: the theme's link colour (blue, stronger in dark) put blue text on the gradient. */
.upgrade-modal__btn--primary,
.upgrade-modal a.upgrade-modal__btn--primary:is(:link, :visited, :hover, :focus) {
    background: var(--upgrade-gradient);
    border: 1px solid transparent; /* same height as the bordered button beside it */
    color: #fff !important;
    box-shadow: 0 8px 24px -8px rgba(99, 102, 241, 0.5);
}

.upgrade-modal__btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px -8px rgba(99, 102, 241, 0.65);
}

.upgrade-modal__btn--primary i {
    margin: 0;
}

/* ─── Warning Variant (Downgrade) ─── */
.upgrade-modal--warning {
    --upgrade-glow: rgba(251, 146, 60, 0.35);
    --upgrade-gradient: linear-gradient(135deg, #f97316, #fb923c, #fbbf24);
}

.upgrade-modal--warning .upgrade-modal__icon {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.15), rgba(251, 191, 36, 0.12));
}

.upgrade-modal--warning .upgrade-modal__title {
    background: linear-gradient(135deg, #f97316, #fb923c, #fbbf24);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.upgrade-modal--warning .upgrade-modal__btn--primary {
    background: linear-gradient(135deg, #f97316, #fb923c);
    box-shadow: 0 8px 24px -8px rgba(249, 115, 22, 0.5);
}

.upgrade-modal--warning .upgrade-modal__btn--primary:hover {
    box-shadow: 0 12px 32px -8px rgba(249, 115, 22, 0.65);
}

/* ─── Affected Items List ─── */
.upgrade-modal__list {
    max-height: 200px;
    overflow-y: auto;
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: var(--upgrade-list-bg);
    border-radius: 0.75rem;
    text-align: left;
}

.upgrade-modal__list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.85rem;
    color: var(--upgrade-text-muted);
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.upgrade-modal__list-item:last-child {
    border-bottom: none;
}

.upgrade-modal__list-item i {
    color: #f97316;
    font-size: 1rem;
}

.upgrade-modal__countdown {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    background: rgba(251, 146, 60, 0.15);
    border: 1px solid rgba(251, 146, 60, 0.25);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fb923c;
    margin-bottom: 1.25rem;
}

.upgrade-modal__countdown i {
    font-size: 1rem;
}
