/* ===== Diet Theme Variables ===== */
:root {
    /* 색상 팔레트 - 다이어트에 적합한 차분한 색상 */
    --primary-color: #FF3B30;
    --primary-dark: #D32F2F;
    --secondary-color: #FF9500;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --info-color: #007AFF;

    /* 배경색 */
    --bg-white: #FFFFFF;
    --bg-gray: #F5F5F7;
    --bg-gray-light: #FAFAFA;

    /* 텍스트 */
    --text-primary: #000000;
    --text-secondary: #6E6E73;
    --text-tertiary: #8E8E93;

    /* 테두리 & 그림자 */
    --border-color: #E5E5EA;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Border Radius */
    --border-radius: 12px;
    --border-radius-lg: 20px;

    /* Transition */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: var(--bg-gray-light);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: 32px;
    padding: 20px;
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.logo {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Navigation ===== */
.nav-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-white);
    padding: 8px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    min-width: 70px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--bg-gray);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.card h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
}

/* ===== Tab Contents ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ===== Goal Card ===== */
.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.weight-display {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--bg-gray);
    border-radius: var(--border-radius);
}

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

.weight-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

.weight-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.weight-item.current .weight-value {
    color: var(--info-color);
}

.weight-item.goal .weight-value {
    color: var(--success-color);
}

.weight-unit {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-left: 4px;
}

.weight-arrow {
    font-size: 20px;
    color: var(--text-tertiary);
}

.goal-progress-bar {
    height: 12px;
    background: var(--bg-gray);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.goal-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--info-color));
    border-radius: 10px;
    transition: width 0.5s ease;
}

.goal-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.goal-stat {
    text-align: center;
    padding: 16px;
    background: var(--bg-gray);
    border-radius: var(--border-radius);
}

.goal-stat .stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.goal-stat .stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Fasting Card ===== */
.fasting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    border-radius: 28px;
    transition: var(--transition);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: var(--transition);
}

input:checked + .toggle-slider {
    background-color: var(--success-color);
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

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

.fasting-mode {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.timer-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.time-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary-color);
}

.time-separator {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-tertiary);
}

.fasting-state {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.fasting-progress-bar {
    height: 8px;
    background: var(--bg-gray);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.fasting-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
    transition: width 0.5s ease;
}

.fasting-setup {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fasting-mode-select {
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* ===== Calorie Card ===== */
.calorie-circle-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 24px;
}

.calorie-circle {
    width: 100%;
    height: 100%;
}

.calorie-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.calorie-consumed {
    font-size: 40px;
    font-weight: 700;
    color: var(--primary-color);
}

.calorie-divider {
    font-size: 24px;
    color: var(--text-tertiary);
}

.calorie-target {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-secondary);
}

.calorie-label {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.calorie-detail {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.calorie-item {
    padding: 16px;
    border-radius: var(--border-radius);
    text-align: center;
}

.calorie-item.remaining {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.1), rgba(52, 199, 89, 0.2));
}

.calorie-item.deficit {
    background: linear-gradient(135deg, rgba(255, 59, 48, 0.1), rgba(255, 59, 48, 0.2));
}

.calorie-item-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.calorie-item-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== Meals ===== */
.meals-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* ===== Analysis ===== */
.analyze-description {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.warning-box {
    background: linear-gradient(135deg, rgba(255, 149, 0, 0.1), rgba(255, 149, 0, 0.2));
    border: 2px solid var(--warning-color);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
    color: var(--warning-color);
}

.analysis-mode-toggle {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 8px;
    background: var(--bg-gray);
    border-radius: var(--border-radius);
}

.mode-option {
    flex: 1;
    text-align: center;
    cursor: pointer;
}

.mode-option input {
    display: none;
}

.mode-label {
    display: block;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
}

.mode-option input:checked + .mode-label {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.camera-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-camera, .btn-gallery {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.btn-camera:hover, .btn-gallery:hover {
    background: var(--border-color);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-danger {
    background: var(--primary-color);
    color: white;
}

.image-preview {
    text-align: center;
    margin-bottom: 20px;
}

.image-preview img {
    max-width: 100%;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.result-section {
    margin-top: 24px;
}

.result-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.food-info {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--bg-gray);
    border-radius: var(--border-radius);
}

.food-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.food-calories {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
}

.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.nutrition-item {
    padding: 16px;
    background: var(--bg-gray);
    border-radius: var(--border-radius);
    text-align: center;
}

.nutrition-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.nutrition-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.diet-advice {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.1), rgba(0, 122, 255, 0.2));
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.advice-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.advice-content {
    flex: 1;
}

.advice-content strong {
    display: block;
    margin-bottom: 4px;
    color: var(--info-color);
}

.advice-content p {
    font-size: 14px;
    color: var(--text-secondary);
}

.exercise-conversion {
    margin-bottom: 20px;
}

.exercise-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

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

.result-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* ===== Progress Tab ===== */
.photo-comparison {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

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

.photo-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.photo-placeholder {
    width: 100%;
    aspect-ratio: 3/4;
    background: var(--bg-gray);
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.photo-placeholder p {
    font-size: 14px;
    color: var(--text-secondary);
}

.weekly-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-box {
    padding: 20px;
    background: var(--bg-gray);
    border-radius: var(--border-radius);
    text-align: center;
}

.stat-box .stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.stat-box .stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Planner Tab ===== */
.week-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.btn-icon {
    background: var(--bg-gray);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.week-label {
    font-size: 16px;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

/* ===== Recipes Tab ===== */
.recipe-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.filter-btn {
    padding: 10px 20px;
    background: var(--bg-gray);
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.filter-btn:hover {
    background: var(--border-color);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
}

.recipe-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.recipe-card {
    background: var(--bg-gray);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.recipe-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.recipe-image {
    font-size: 48px;
    margin-bottom: 12px;
}

.recipe-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
}

.recipe-calories {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.recipe-description {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== Settings Tab ===== */
.setting-section {
    margin-bottom: 32px;
    padding-bottom: 32px;
    border-bottom: 2px solid var(--bg-gray);
}

.setting-section:last-child {
    border-bottom: none;
}

.setting-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.setting-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.setting-description a {
    color: var(--info-color);
    text-decoration: underline;
}

.input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.input-field {
    flex: 1;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
}

.api-key-status {
    text-align: center;
    font-size: 13px;
}

.goal-inputs {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.input-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.data-actions {
    display: flex;
    gap: 12px;
}

/* ===== Utility ===== */
.hidden {
    display: none !important;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ===== Loading ===== */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-gray);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading p {
    margin-top: 20px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: var(--border-radius-lg);
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

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

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .weight-display {
        flex-direction: column;
        gap: 16px;
    }

    .weight-arrow {
        transform: rotate(90deg);
    }

    .goal-stats {
        grid-template-columns: 1fr;
    }

    .nutrition-grid {
        grid-template-columns: 1fr;
    }

    .calorie-detail {
        grid-template-columns: 1fr;
    }

    .photo-comparison {
        grid-template-columns: 1fr;
    }

    .weekly-stats {
        grid-template-columns: 1fr;
    }

    .recipe-grid {
        grid-template-columns: 1fr;
    }

    .data-actions {
        flex-direction: column;
    }
}
