/* ─── Tier Widget (inside user popover) ─── */

.tier-widget {
    width: 100%;
    padding: 8px 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background var(--transition-normal);
    text-align: left;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    -webkit-tap-highlight-color: transparent;
}

.tier-widget:hover {
    background: var(--border);
}

.tier-widget:active {
    transform: scale(0.98);
}

.tier-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tier-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.tier-quota-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.tier-progress-track {
    background: var(--border);
    border-radius: var(--radius-full);
    height: 3px;
    overflow: hidden;
}

.tier-progress-bar {
    background: var(--accent);
    border-radius: var(--radius-full);
    height: 100%;
    min-width: 0;
    transition: width 0.4s ease, background-color 0.3s ease;
}

.tier-progress-bar.warning {
    background: var(--warning, #f59e0b);
}

.tier-progress-bar.critical {
    background: var(--error, #ef4444);
}

/* ─── Tier Info Modal ─── */

.tier-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 500);
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: flex-end;
    justify-content: center;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.tier-modal-backdrop.visible {
    display: flex;
}

.tier-modal-content {
    background: var(--bg-color);
    border-radius: var(--radius-lg, 16px) var(--radius-lg, 16px) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: tierModalSlideUp 0.25s ease-out;
    -webkit-overflow-scrolling: touch;
}

@keyframes tierModalSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.tier-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-color);
    z-index: 1;
}

.tier-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tier-modal-title .tier-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
}

.tier-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    transition: background var(--transition-normal);
    -webkit-tap-highlight-color: transparent;
}

.tier-modal-close:hover {
    background: var(--border);
}

.tier-modal-body {
    padding: 16px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Quota section */
.tier-quota-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tier-quota-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.tier-quota-detail {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.tier-quota-current {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.tier-quota-separator {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tier-quota-limit {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1;
}

.tier-quota-period {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.tier-modal-progress-track {
    background: var(--border);
    border-radius: var(--radius-full);
    height: 6px;
    overflow: hidden;
}

.tier-modal-progress-bar {
    background: var(--accent);
    border-radius: var(--radius-full);
    height: 100%;
    transition: width 0.4s ease;
}

.tier-modal-progress-bar.warning {
    background: var(--warning, #f59e0b);
}

.tier-modal-progress-bar.critical {
    background: var(--error, #ef4444);
}

.tier-token-usage {
    font-size: 12px;
    color: var(--text-muted, #71717a);
    margin-top: 6px;
}

/* Features section */
.tier-features-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tier-feature-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tier-feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.tier-feature-item i {
    width: 16px;
    text-align: center;
    font-size: 0.75rem;
}

.tier-feature-allowed i {
    color: var(--accent);
}

.tier-feature-blocked i {
    color: var(--text-muted);
    opacity: 0.5;
}

.tier-feature-blocked .tier-feature-label {
    color: var(--text-muted);
}

.tier-feature-value {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Limits section */
.tier-limits-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tier-limit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 0.85rem;
}

.tier-limit-label {
    color: var(--text-secondary);
}

.tier-limit-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Feature-locked button styling */
.feature-locked {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
    position: relative;
    user-select: none;
}

/* Desktop: center modal */
@media (min-width: 600px) {
    .tier-modal-backdrop {
        align-items: center;
    }

    .tier-modal-content {
        border-radius: var(--radius-lg, 16px);
        max-height: 70vh;
    }

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

/* ── Upgrade Prompt Overlay ──────────────────────────────── */

.upgrade-prompt-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.upgrade-prompt-overlay.visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.5);
}

.upgrade-prompt-overlay.closing {
    opacity: 0;
}

.upgrade-prompt-sheet {
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 16px;
    padding: 28px 24px 20px;
    max-width: 380px;
    width: calc(100% - 32px);
    text-align: center;
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.upgrade-prompt-overlay.visible .upgrade-prompt-sheet {
    transform: translateY(0);
}

.upgrade-prompt-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.upgrade-prompt-header svg {
    color: var(--accent-color, #6366f1);
    width: 40px;
    height: 40px;
}

.upgrade-prompt-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #e0e0e0);
}

.upgrade-trial-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.upgrade-prompt-message {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary, #a0a0b0);
}

.upgrade-prompt-current {
    margin: 0 0 20px;
    font-size: 13px;
    color: var(--text-tertiary, #707080);
}

.upgrade-prompt-current strong {
    color: var(--text-primary, #e0e0e0);
}

.upgrade-prompt-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.upgrade-prompt-btn {
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.upgrade-prompt-btn:active {
    transform: scale(0.98);
}

.upgrade-prompt-btn.primary {
    background: var(--accent-color, #6366f1);
    color: #fff;
}

.upgrade-prompt-btn.primary:hover {
    opacity: 0.9;
}

.upgrade-prompt-btn.secondary {
    background: transparent;
    color: var(--text-secondary, #a0a0b0);
}

.upgrade-prompt-btn.secondary:hover {
    color: var(--text-primary, #e0e0e0);
}

/* Mobile: bottom sheet variant */
.upgrade-prompt-overlay.mobile {
    align-items: flex-end;
}

.upgrade-prompt-overlay.mobile .upgrade-prompt-sheet {
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    transform: translateY(100%);
}

.upgrade-prompt-overlay.mobile.visible .upgrade-prompt-sheet {
    transform: translateY(0);
}

/* Light theme overrides */
.light-theme .upgrade-prompt-sheet {
    background: var(--bg-secondary, #fff);
    border-color: var(--border-color, rgba(0,0,0,0.1));
}

.light-theme .upgrade-prompt-header h3 {
    color: var(--text-primary, #1a1a2e);
}

.light-theme .upgrade-prompt-message {
    color: var(--text-secondary, #555);
}

.light-theme .upgrade-prompt-current {
    color: var(--text-tertiary, #888);
}

.light-theme .upgrade-prompt-current strong {
    color: var(--text-primary, #1a1a2e);
}

.light-theme .upgrade-prompt-btn.secondary {
    color: var(--text-secondary, #555);
}

.light-theme .upgrade-prompt-btn.secondary:hover {
    color: var(--text-primary, #1a1a2e);
}
