/* ===== 영양 분석 리포트 페이지 ===== */

:root {
    --rp-pink: #ec4899;
    --rp-purple: #a855f7;
    --rp-gradient: linear-gradient(135deg, #ec4899, #a855f7);
    --color-carbs: #FF6B8A;
    --color-protein: #A78BFA;
    --color-fat: #FBBF24;
    --font-outfit: 'Outfit', sans-serif;
}

/* ===== 헤더 ===== */
.rp-header {
    text-align: left;
    margin-bottom: 1.5rem;
}

.rp-header .page-title-area {
    margin-top: 1.5rem;
}

.rp-header h1 {
    font-family: var(--font-outfit);
    font-size: 2rem;
    font-weight: 800;
    background: var(--rp-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.rp-header .subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
}

/* ===== 요약 섹션 ===== */
.summary-section {
    margin-bottom: 1.5rem;
}

.summary-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.summary-day-badge {
    font-family: var(--font-outfit);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--rp-pink);
    background: linear-gradient(135deg, rgba(236,72,153,0.1), rgba(168,85,247,0.08));
    border: 1px solid rgba(236,72,153,0.2);
    border-radius: 20px;
    padding: 4px 14px;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

.summary-sub {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* 4열 카드 그리드 */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.summary-card {
    background: rgba(255, 255, 255, 0.62);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 18px;
    padding: 14px 10px;
    text-align: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: cardSlideUp 0.5s ease-out both;
}

.summary-card:nth-child(1) { animation-delay: 0.05s; }
.summary-card:nth-child(2) { animation-delay: 0.10s; }
.summary-card:nth-child(3) { animation-delay: 0.15s; }
.summary-card:nth-child(4) { animation-delay: 0.20s; }

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

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.07);
}

.sc-cal   { border-bottom: 3px solid var(--rp-pink); }
.sc-carbs { border-bottom: 3px solid var(--color-carbs); }
.sc-protein { border-bottom: 3px solid var(--color-protein); }
.sc-fat   { border-bottom: 3px solid var(--color-fat); }

.sc-icon {
    font-size: 1.25rem;
    margin-bottom: 5px;
}

.sc-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}

.sc-value {
    display: block;
    font-family: var(--font-outfit);
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-color);
    line-height: 1.1;
}

/* ===== 막대 그래프 섹션 ===== */
.bar-section {
    margin-bottom: 2rem;
}

.bar-card {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(236, 72, 153, 0.08), 0 2px 8px rgba(0, 0, 0, 0.02);
}

.bar-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 10px;
}

/* 차트 모드 토글 버튼 */
.chart-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 10px 4px 6px;
    border-radius: 20px;
    transition: background 0.2s ease;
    font-family: var(--font-outfit);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-color);
    margin: -4px -6px;
}

.chart-mode-toggle:hover {
    background: linear-gradient(135deg, rgba(236,72,153,0.08), rgba(168,85,247,0.06));
}

.toggle-swap-icon {
    color: var(--rp-purple);
    opacity: 0.55;
    flex-shrink: 0;
    transition: transform 0.35s ease, opacity 0.2s ease;
}

.chart-mode-toggle:hover .toggle-swap-icon {
    opacity: 1;
    transform: rotate(180deg);
}

.unit-hint {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* 레전드 */
.bar-legend {
    display: flex;
    gap: 12px;
    align-items: center;
}

.bl-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}

.bl-dot {
    width: 9px;
    height: 9px;
    border-radius: 3px;
    flex-shrink: 0;
}

.dot-carbs    { background: var(--color-carbs); }
.dot-protein  { background: var(--color-protein); }
.dot-fat      { background: var(--color-fat); }
.dot-calories { background: linear-gradient(135deg, var(--rp-pink), var(--rp-purple)); }

/* Y축 고정 + 스크롤 차트 컨테이너 */
.bar-chart-container {
    display: flex;
    align-items: flex-start;
}

.bar-yaxis-panel {
    flex-shrink: 0;
    width: 42px;
    height: 260px;
    position: relative;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 2;
}

.y-axis-label {
    position: absolute;
    right: 4px;
    transform: translateY(-50%);
    font-family: 'Inter', sans-serif;
    font-size: 10.5px;
    font-weight: 500;
    color: #94a3b8;
    white-space: nowrap;
    line-height: 1;
    pointer-events: none;
}

/* 스크롤 가능한 차트 래퍼 */
.bar-chart-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    /* 스크롤바 스타일 */
    scrollbar-width: thin;
    scrollbar-color: rgba(236, 72, 153, 0.2) transparent;
}

.bar-chart-scroll::-webkit-scrollbar {
    height: 4px;
}

.bar-chart-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.bar-chart-scroll::-webkit-scrollbar-thumb {
    background: rgba(236, 72, 153, 0.2);
    border-radius: 4px;
}

.bar-chart-inner {
    position: relative;
    height: 260px;
}

/* ===== 빈 상태 ===== */
.rp-empty {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    border: 1px dashed rgba(236, 72, 153, 0.2);
    margin-bottom: 2rem;
}

.rp-empty .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.rp-empty p {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
}

.rp-empty .hint {
    font-size: 0.82rem;
    margin-top: 6px;
    opacity: 0.7;
}

.hidden {
    display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .rp-header h1 {
        font-size: 1.7rem;
    }

    .summary-cards {
        gap: 8px;
    }

    .summary-card {
        padding: 12px 6px;
    }

    .sc-value {
        font-size: 0.9rem;
    }

    .sc-label {
        font-size: 0.58rem;
    }

    .bar-card {
        padding: 1.25rem 1rem;
    }

    .bar-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .bar-chart-inner {
        height: 220px;
    }

    .bar-yaxis-panel {
        height: 220px;
    }
}

/* ===== 바 클릭 날짜별 식사 기록 ===== */
.day-detail-section {
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.day-detail-section.hidden {
    display: none;
}

.day-detail-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.day-detail-card {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(236, 72, 153, 0.08);
}

.day-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.day-detail-date-label {
    font-family: var(--font-outfit, 'Outfit', sans-serif);
    font-size: 0.9rem;
    font-weight: 700;
    background: var(--rp-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.day-detail-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(236, 72, 153, 0.18);
    background: rgba(236, 72, 153, 0.05);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
    flex-shrink: 0;
}

.day-detail-close-btn:hover {
    background: rgba(236, 72, 153, 0.12);
    color: var(--rp-pink);
    border-color: rgba(236, 72, 153, 0.35);
}

.day-detail-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 식사 기록 카드 */
.dd-record-card {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 14px;
    padding: 12px 14px;
    animation: ddCardIn 0.3s ease-out both;
}

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

.dd-record-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.dd-time {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--rp-pink);
    background: rgba(236, 72, 153, 0.08);
    padding: 3px 9px;
    border-radius: 20px;
}

.dd-calories {
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    color: #1e293b;
}

.dd-calories small {
    font-size: 0.68rem;
    font-weight: 500;
    color: #94a3b8;
    margin-left: 1px;
}

.dd-items {
    font-size: 0.82rem;
    color: #475569;
    line-height: 1.5;
    margin-bottom: 8px;
    word-break: keep-all;
}

.dd-macro-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.dd-tag {
    font-size: 0.72rem;
    color: #64748b;
    background: rgba(0, 0, 0, 0.04);
    padding: 2px 8px;
    border-radius: 20px;
}

.dd-tag b {
    color: #334155;
    margin-left: 2px;
}

.dd-tag.tag-carbs   { background: rgba(255, 107, 138, 0.1); }
.dd-tag.tag-protein { background: rgba(167, 139, 250, 0.1); }
.dd-tag.tag-fat     { background: rgba(251, 191, 36,  0.1); }

/* 빈 기록 상태 */
.dd-empty {
    text-align: center;
    padding: 24px 0 12px;
    color: #94a3b8;
}

.dd-empty-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.dd-empty p {
    font-size: 0.85rem;
    font-weight: 500;
}

/* ===== 바 차트 커스텀 툴팁 풍선 ===== */
.bar-tooltip {
    position: absolute;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(236, 72, 153, 0.14);
    border-radius: 20px;
    padding: 14px 16px 12px;
    min-width: 196px;
    max-width: 248px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.04),
        0 14px 40px rgba(0, 0, 0, 0.11),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    pointer-events: none;
    opacity: 0;
    transform: scale(0.92) translateY(10px);
    transition:
        opacity 0.22s cubic-bezier(0.34, 1.4, 0.64, 1),
        transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
    will-change: opacity, transform;
}

.bar-tooltip.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* 아래방향 화살표 (툴팁이 클릭 위쪽에 위치) */
.bar-tooltip.arrow-down::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%) rotate(45deg);
    width: 11px;
    height: 11px;
    background: rgba(255, 255, 255, 0.96);
    border-right: 1px solid rgba(236, 72, 153, 0.14);
    border-bottom: 1px solid rgba(236, 72, 153, 0.14);
}

/* 위방향 화살표 (툴팁이 클릭 아래쪽에 위치) */
.bar-tooltip.arrow-up::after {
    content: '';
    position: absolute;
    top: -6px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%) rotate(45deg);
    width: 11px;
    height: 11px;
    background: rgba(255, 255, 255, 0.96);
    border-left: 1px solid rgba(236, 72, 153, 0.14);
    border-top: 1px solid rgba(236, 72, 153, 0.14);
}

/* 날짜 헤더 */
.btt-date {
    display: block;
    font-family: var(--font-outfit, 'Outfit', sans-serif);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: var(--rp-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

/* 구분선 */
.btt-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(236, 72, 153, 0.12), transparent);
    margin: 8px 0;
}

/* 매크로 행 */
.btt-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3.5px 0;
}

.btt-dot {
    width: 8px;
    height: 8px;
    border-radius: 3px;
    flex-shrink: 0;
}

.btt-dot-carbs   { background: #FF6B8A; }
.btt-dot-protein { background: #A78BFA; }
.btt-dot-fat     { background: #FBBF24; }
.btt-dot-cal     { background: linear-gradient(135deg, #ec4899, #a855f7); border-radius: 50%; }

.btt-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    flex: 1;
}

.btt-g {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1e293b;
    font-variant-numeric: tabular-nums;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.01em;
}

.btt-pct {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    font-variant-numeric: tabular-nums;
    font-family: 'Inter', sans-serif;
    min-width: 36px;
    text-align: center;
}

.btt-pct-carbs   { background: rgba(255, 107, 138, 0.12); color: #e85577; }
.btt-pct-protein { background: rgba(167, 139, 250, 0.14); color: #7c5cbf; }
.btt-pct-fat     { background: rgba(251, 191, 36,  0.14); color: #b97c14; }

/* 합계 행 */
.btt-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 2px;
}

.btt-total-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #94a3b8;
}

.btt-total-g {
    font-size: 0.84rem;
    font-weight: 800;
    color: #1e293b;
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}
