/* Toast Notification Styles */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10020;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--color-bg-primary, #ffffff);
    color: var(--color-text-primary, #333);
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    border: 1px solid var(--color-border, #eee);
    min-width: 200px;
    justify-content: center;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-left: 4px solid var(--color-success, #22c55e);
}

.toast-error {
    border-left: 4px solid var(--color-danger, #ef4444);
}

.toast-info {
    border-left: 4px solid var(--color-accent-primary, #d97757);
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
}

.toast-message {
    white-space: pre-line;
    text-align: left;
    line-height: 1.45;
}

/* Level Badge with Instant Tooltip */
.level-badge-wrap {
    position: relative;
    display: inline;
    margin-left: 4px;
    vertical-align: baseline;
}

.level-badge {
    font-size: 0.7em;
    padding: 1px 6px;
    border-radius: 4px;
    cursor: help;
    white-space: nowrap;
}

.level-badge-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 6px;
    padding: 8px 12px;
    background: var(--color-bg-primary, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: nowrap;
    z-index: 100;
    transition:
        opacity 0.1s ease,
        visibility 0.1s ease;
}

.level-badge-wrap:hover .level-badge-tooltip {
    visibility: visible;
    opacity: 1;
}

.level-badge-wrap:focus-within .level-badge-tooltip {
    visibility: visible;
    opacity: 1;
}

.level-badge-wrap:focus-within .level-badge {
    outline: 2px solid rgba(217, 119, 87, 0.35);
    outline-offset: 2px;
}

/* Level Badge Color Variants - 使用 data-level 属性驱动 */
.level-badge[data-level='basic'] {
    background: #e0f2fe;
    color: #0369a1;
}

.level-badge[data-level='pro'] {
    background: #ede9fe;
    color: #7c3aed;
}

.level-badge[data-level='ultra'] {
    background: #ffe4e6;
    color: #be123c;
}

.level-badge[data-level='expired'] {
    background: #fef2f2;
    color: #dc2626;
}

/* 后备额度徽章 */
.reserve-badge {
    font-size: 0.65em;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    cursor: help;
    white-space: nowrap;
    vertical-align: baseline;
}

/* Shared Section Toggle Button */
.section-toggle-btn {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    line-height: 1;
    transition:
        transform 0.3s ease,
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

.section-toggle-btn:hover {
    background: rgba(74, 62, 53, 0.08);
    border-color: var(--color-border-hover);
    color: var(--color-text-secondary);
}

/* 按钮旋转逻辑 - Generic for containers using .collapsed class */
.nutrition-chart-container.collapsed .section-toggle-btn,
.advice-section.collapsed .section-toggle-btn,
.collapsed .section-toggle-btn {
    transform: rotate(-90deg);
}

/* 通用折叠动画：Scheme A (Grid Template Rows) */
.section-wrapper {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapsed .section-wrapper {
    grid-template-rows: 0fr;
}

.section-body {
    overflow: hidden;
    min-height: 0;
    /* Necessary for grid fr calculation */
}

body.session-expired-locked {
    overflow: hidden;
}

/* 会话失效全局锁层 */
.auth-session-expired-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(2px);
}

.auth-session-expired-dialog {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    width: min(92vw, 360px);
    padding: 18px 18px 16px;
    background: rgba(255, 251, 235, 0.98);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.auth-session-expired-title {
    font-size: 0.96rem;
    line-height: 1.6;
    color: #92400e;
    text-align: center;
}

.auth-session-expired-btn {
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    background: #d97757;
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.auth-session-expired-btn:hover {
    background: #c56342;
}

@media (max-width: 640px) {
    .auth-session-expired-dialog {
        width: min(94vw, 320px);
        padding: 16px 14px 14px;
    }

    .auth-session-expired-title {
        font-size: 0.92rem;
    }
}
