/* Fat Fit - Apple Fitness Style Dark & Light Theme System */

:root {
    /* Light Mode Variables */
    --bg-main: #f2f2f7;
    --bg-card: #ffffff;
    --bg-card-hover: #f9f9fb;
    --bg-card-secondary: #e5e5ea;
    --bg-input: #f2f2f7;
    --text-main: #000000;
    --text-muted: #8e8e93;
    --text-secondary: #3a3a3c;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.04);
    
    /* Neons & Accents */
    --accent-pink: #ff2d55;
    --accent-green: #28cd41;
    --accent-blue: #007aff;
    --accent-purple: #af52de;
    --accent-yellow: #ff9f0a;

    --ring-bg-pink: #fde8ed;
    --ring-bg-green: #e2f9e5;
    --ring-bg-blue: #e0f2ff;

    --nav-bg: rgba(255, 255, 255, 0.82);
    --nav-border: rgba(0, 0, 0, 0.08);
    --nav-active-bg: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
    /* Dark Mode Variables (Apple Fitness Style) */
    --bg-main: #000000;
    --bg-card: #1c1c1e;
    --bg-card-hover: #242428;
    --bg-card-secondary: #2c2c2e;
    --bg-input: #2c2c2e;
    --text-main: #ffffff;
    --text-muted: #8e8e93;
    --text-secondary: #aeaeb2;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Neons & Accents (Vibrant in Dark Mode) */
    --accent-pink: #ff375f;
    --accent-green: #a1e220; /* Apple Fitness Lime */
    --accent-blue: #64d2ff;
    --accent-purple: #bf5af2;
    --accent-yellow: #ffd60a;

    --ring-bg-pink: #3e0a16;
    --ring-bg-green: #1d3303;
    --ring-bg-blue: #0a2636;

    --nav-bg: rgba(28, 28, 30, 0.85);
    --nav-border: rgba(255, 255, 255, 0.12);
    --nav-active-bg: rgba(255, 255, 255, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Noto Sans JP', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    min-height: 100vh;
}

.app-viewport {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 24px 4px 16px 4px;
    position: sticky;
    top: 0;
    background-color: var(--bg-main);
    z-index: 900;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background-color 0.3s ease;
}

.header-left {
    display: flex;
    flex-direction: column;
}

.header-date {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.header-title {
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    background: var(--bg-card-secondary);
    color: var(--text-main);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.3s ease;
}

.icon-btn:active {
    transform: scale(0.92);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* App Content */
.app-content {
    flex: 1;
    padding-bottom: 120px; /* Space for floating nav */
}

.tab-pane {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

.tab-pane.active {
    display: block;
}

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

/* Page Title Section */
.page-title-section {
    margin-bottom: 20px;
}

.page-title-section h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
}

.page-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Cards Base */
.card {
    background-color: var(--bg-card);
    border-radius: 22px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

.card:hover {
    background-color: var(--bg-card-hover);
}

.card-subtitle {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.card-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 2px;
}

/* Activity Ring Card (Apple Fitness Style) */
.ring-card {
    position: relative;
    overflow: hidden;
}

.ring-display-container {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 16px;
    margin: 20px 0;
}

.ring-svg-wrapper {
    position: relative;
    width: 170px;
    height: 170px;
    flex-shrink: 0;
}

.activity-rings-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
}

.ring-pink-bg { stroke: var(--ring-bg-pink); }
.ring-green-bg { stroke: var(--ring-bg-green); }
.ring-blue-bg { stroke: var(--ring-bg-blue); }

.ring-progress {
    fill: none;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.ring-pink { stroke: var(--accent-pink); }
.ring-green { stroke: var(--accent-green); }
.ring-blue { stroke: var(--accent-blue); }

.ring-center-stat {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ring-stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.ring-stat-unit {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 2px;
}

.ring-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.legend-item {
    display: flex;
    flex-direction: column;
}

.legend-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.pink { background-color: var(--accent-pink); }
.dot.green { background-color: var(--accent-green); }
.dot.blue { background-color: var(--accent-blue); }

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

.legend-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.legend-value .unit {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.legend-sub {
    font-size: 0.75rem;
    font-weight: 600;
}

.text-pink { color: var(--accent-pink); }
.text-green { color: var(--accent-green); }
.text-blue { color: var(--accent-blue); }
.text-purple { color: var(--accent-purple); }

/* Buttons */
.action-btn, .submit-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 16px;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.action-btn:active, .submit-btn:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.pink-btn {
    background-color: var(--accent-pink);
    color: #ffffff;
}

.green-btn {
    background-color: var(--accent-green);
    color: #ffffff;
}

[data-theme="dark"] .green-btn {
    color: #000000; /* Dark text on bright lime in dark mode */
}

.blue-btn {
    background-color: var(--accent-blue);
    color: #ffffff;
}

.purple-btn {
    background-color: var(--accent-purple);
    color: #ffffff;
}

/* Metrics Grid / Bento */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.metric-card {
    margin-bottom: 0;
}

.metric-card.full-width {
    grid-column: span 2;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.metric-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
}

.metric-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.blue-bg { background-color: var(--accent-blue); }
.pink-bg { background-color: var(--accent-pink); }
.green-bg { background-color: var(--accent-green); color: #000; }
.yellow-bg { background-color: var(--accent-yellow); color: #000; }
.purple-bg { background-color: var(--accent-purple); }

.advice-content {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1.4;
}

.forecast-stats {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 12px 0;
}

.forecast-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.forecast-value {
    font-size: 1.5rem;
    font-weight: 800;
}

.forecast-divider {
    width: 1px;
    height: 36px;
    background-color: var(--border-color);
}

/* Form Styles */
.input-card h3 {
    font-size: 1.15rem;
    color: var(--text-main);
    margin-bottom: 14px;
}

.card-header-compact {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.card-header-compact h3 {
    margin-bottom: 0;
}

.card-icon-badge {
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row > .form-group {
    flex: 1;
}

.input-with-unit {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s ease, background-color 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: var(--accent-blue);
}

.input-with-unit input {
    padding-right: 50px;
}

.input-unit {
    position: absolute;
    right: 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
}

.inline-btn-group {
    display: flex;
    gap: 10px;
}

.inline-btn-group .input-with-unit, .inline-btn-group input[type="text"] {
    flex: 1;
}

.inline-btn-group .submit-btn {
    width: auto;
    padding: 0 24px;
    flex-shrink: 0;
}

/* Progress Bar */
.progress-bar-container {
    background-color: var(--bg-card-secondary);
    border-radius: 12px;
    height: 22px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar-fill {
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
    height: 100%;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: #ffffff;
    font-weight: 800;
    font-size: 0.75rem;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* List Styles */
.recorded-list-section {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

.list-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
}

.record-list ul {
    list-style: none;
}

.record-list li {
    background-color: var(--bg-card-secondary);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.record-list li .item-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.delete-item-btn {
    background: none;
    border: none;
    color: var(--accent-pink);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    opacity: 0.8;
}

.delete-item-btn:hover {
    opacity: 1;
}

.empty-state {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    padding: 10px 0;
}

/* Plan & Simulator */
.plan-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 14px;
}

.plan-stat-box {
    background-color: var(--bg-card-secondary);
    padding: 12px 8px;
    border-radius: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 800;
    margin-top: 2px;
}

.stat-value .unit {
    font-size: 0.75rem;
    font-weight: 500;
}

.sim-comparison {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}

.sim-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg-card-secondary);
    padding: 14px;
    border-radius: 16px;
}

.sim-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 8px;
}

.sim-badge.current {
    background-color: var(--text-muted);
    color: #ffffff;
}

.sim-badge.target {
    background-color: var(--accent-green);
    color: #000000;
}

.sim-body-figure {
    font-size: 2rem;
    margin: 8px 0;
}

.sim-arrow {
    font-size: 1.5rem;
    color: var(--accent-green);
    padding: 0 8px;
}

/* Graph */
.graph-header-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.period-button-group {
    display: flex;
    background-color: var(--bg-card-secondary);
    padding: 4px;
    border-radius: 14px;
    gap: 4px;
}

.graph-period-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.graph-period-btn.active {
    background-color: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-container {
    width: 100%;
    min-height: 220px;
    background-color: var(--bg-card-secondary);
    border-radius: 16px;
    padding: 16px;
    margin-top: 10px;
}

/* Trophy & Guides */
.trophy-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 14px;
}

.trophy-item {
    background-color: var(--bg-card-secondary);
    border-radius: 18px;
    padding: 16px;
    text-align: center;
    opacity: 0.45;
    transition: opacity 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
    border: 1px solid transparent;
}

.trophy-item.unlocked {
    opacity: 1;
    border-color: var(--accent-yellow);
    background: linear-gradient(180deg, var(--bg-card-secondary), var(--bg-card));
}

.trophy-item .trophy-icon {
    font-size: 2.2rem;
    margin-bottom: 6px;
}

.trophy-item h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.trophy-item p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.workout-guide-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.guide-box {
    background-color: var(--bg-card-secondary);
    padding: 12px;
    border-radius: 14px;
}

.guide-box h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 8px;
}

.guide-box ul {
    padding-left: 16px;
    font-size: 0.85rem;
    color: var(--text-main);
}

.food-ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-card-secondary);
    padding: 12px;
    border-radius: 14px;
}

.rank-badge {
    font-size: 0.8rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 10px;
    color: #ffffff;
}

.rank-1 .rank-badge { background-color: var(--accent-pink); }
.rank-2 .rank-badge { background-color: var(--accent-yellow); color: #000; }
.rank-3 .rank-badge { background-color: var(--accent-green); color: #000; }

.rank-info {
    display: flex;
    flex-direction: column;
}

.rank-info strong {
    font-size: 0.95rem;
    color: var(--text-main);
}

.rank-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Floating Navigation (Apple iOS Bottom Pill Nav) */
.floating-nav {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 520px;
    z-index: 1000;
    background-color: var(--nav-bg);
    border: 1px solid var(--nav-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 36px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    padding: 6px 8px;
    transition: background-color 0.3s ease;
}

.tab-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    border-radius: 20px;
    cursor: pointer;
    flex: 1;
    transition: color 0.2s ease, transform 0.15s ease, background-color 0.2s ease;
}

.nav-item:active {
    transform: scale(0.92);
}

.nav-item.active {
    color: var(--accent-green);
    background-color: var(--nav-active-bg);
}

.nav-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
}

.nav-label {
    font-size: 0.68rem;
    font-weight: 700;
    margin-top: 2px;
    letter-spacing: -0.2px;
}

/* Helper Utilities */
.small-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.center-text {
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Mobile & Display Tweaks */
@media (max-width: 480px) {
    .ring-display-container {
        flex-direction: column;
    }
    .ring-svg-wrapper {
        width: 160px;
        height: 160px;
    }
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    .metric-card.full-width {
        grid-column: span 1;
    }
    .plan-stats-grid {
        grid-template-columns: 1fr;
    }
    .workout-guide-grid {
        grid-template-columns: 1fr;
    }
    .trophy-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
