/* =========================================================================
   NutriLogic 脈動代謝｜樣式系統 (styles.css)
   ========================================================================= */

:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #ecfdf5;
    --carb-color: #3b82f6;
    --carb-light: #eff6ff;
    --pro-color: #f59e0b;
    --pro-light: #fffbeb;
    --fat-color: #ec4899;
    --fat-light: #fdf2f8;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #eab308;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-card-glass: rgba(30, 41, 59, 0.88);
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

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

body {
    font-family: 'Plus Jakarta Sans', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 15px;
    padding-bottom: 60px;
}

/* 頂部導航列 */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 10vw;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 20px;
    background: linear-gradient(135deg, #34d399, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-logo-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: contain;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.logo-badge {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 700;
    border: 1px solid rgba(52, 211, 153, 0.3);
    -webkit-text-fill-color: initial;
}

.nav-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-sm:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.auth-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cloud-dot {
    width: 7px;
    height: 7px;
    background-color: #34d399;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px #34d399;
}

/* 主容器 */
.container {
    width: 80%;
    max-width: none;
    margin: 20px auto;
}

@media (max-width: 900px) {
    .container {
        width: 94%;
        margin: 12px auto;
    }
    .navbar {
        padding: 10px 3vw;
    }
    .logo {
        font-size: 17px;
    }
}

/* 統一卡片容器 */
.card {
    background: var(--bg-card-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 22px;
    margin-bottom: 18px;
    box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.4);
}

@media (max-width: 600px) {
    .card {
        padding: 14px;
    }
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.card-title {
    font-size: 18px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 模式切換器 */
.mode-switch-container {
    display: flex;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 14px;
    gap: 6px;
}

.mode-btn {
    flex: 1;
    padding: 9px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.mode-btn.active.pro {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

/* 日期導航列 */
.date-navigator-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

/* 表單網格 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 700;
}

input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], select {
    width: 100%;
    padding: 10px 12px;
    background-color: #1e293b !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: #f8fafc !important;
    font-size: 15px;
    font-weight: 600;
    outline: none;
    transition: all 0.2s;
}

select option {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    padding: 10px;
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* 宏量營養素儀表板 */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.metric-tile {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 12px;
    text-align: center;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.metric-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.metric-tile.cal::before { background: var(--primary); }
.metric-tile.pro::before { background: var(--pro-color); }
.metric-tile.fat::before { background: var(--fat-color); }
.metric-tile.carb::before { background: var(--carb-color); }

.tile-name {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.tile-val {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 4px 0;
}

.tile-range-box {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.tile-status-tag {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    margin: 0 auto;
}

.status-good { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-under { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.status-over { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* 教練提示卡片 */
.alerts-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-card {
    background: rgba(15, 23, 42, 0.5);
    border-left: 3px solid var(--border-color);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}

.alert-card.good { border-left-color: #10b981; background: rgba(16, 185, 129, 0.06); color: #d1fae5; }
.alert-card.under { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.06); color: #dbeafe; }
.alert-card.over { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.06); color: #fef3c7; }

.alert-title {
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    transition: all 0.2s;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* 飲食清單項目 */
.log-item {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: grab;
}

.log-item:hover {
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(30, 41, 59, 0.7);
}

.log-item.dragging {
    opacity: 0.3;
    border: 1.5px dashed #38bdf8;
}

.log-item.drag-over {
    border-top: 2px solid #34d399;
}

.drag-handle {
    color: var(--text-muted);
    font-size: 18px;
    cursor: grab;
    user-select: none;
    padding: 0 2px;
}

.log-content {
    flex: 1;
    min-width: 0;
}

.log-name {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-macros {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.log-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-move {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.macro-dot { display: inline-flex; align-items: center; gap: 3px; }
.macro-dot.cal { color: #34d399; font-weight: 700; }
.macro-dot.pro { color: var(--pro-color); }
.macro-dot.fat { color: var(--fat-color); }
.macro-dot.carb { color: var(--carb-color); }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-size: 14px;
}
.btn-icon:hover { color: var(--danger); }

/* 每週排程器 */
.weekly-schedule-bar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin: 10px 0 4px 0;
}

@media (max-width: 768px) {
    .weekly-schedule-bar {
        grid-template-columns: repeat(4, 1fr);
    }
}

.day-schedule-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 4px;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.day-schedule-card.today {
    box-shadow: 0 0 0 1.5px #38bdf8;
}

.day-schedule-card.low { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); }
.day-schedule-card.high { background: rgba(139, 92, 246, 0.15); border-color: rgba(139, 92, 246, 0.5); }
.day-schedule-card.tdee { background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.5); }

.day-name { font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 2px; }
.day-tag { font-size: 11px; font-weight: 800; padding: 2px 5px; border-radius: 4px; display: inline-block; }
.day-tag.low { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.day-tag.high { background: rgba(139, 92, 246, 0.3); color: #c084fc; }
.day-tag.tdee { background: rgba(245, 158, 11, 0.3); color: #fbbf24; }

.badge-amber { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }

/* Modal 彈窗樣式 (左右各留白 10%) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 14px;
}

.modal-content {
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 80%;
    max-width: 1400px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

@media (max-width: 900px) {
    .modal-content {
        width: 94%;
    }
}

/* 標籤頁 (Tabs) */
.tab-bar {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    padding-bottom: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 700;
    padding: 6px 14px;
    cursor: pointer;
    border-radius: 6px;
}

.tab-btn.active {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
}

/* 表格樣式 */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}
.custom-table th, .custom-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}
.custom-table th { color: var(--text-muted); font-size: 12px; }

.hidden { display: none !important; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.badge-green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #c084fc; }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* 🌟 代謝測驗步驟顯示/隱藏控制 (修復測驗全部同時顯示問題) */
.quiz-step {
    display: none !important;
}
.quiz-step.active {
    display: block !important;
}
