/* ============================================================= */
/*  Core Variables                                               */
/* ============================================================= */
:root {
	--primary-bg: #000000;
	--container-bg: #ffffff;
	--button-bg: #cb001b;
	--highlight-bg: #f7c961;
	--border-color: #ccc;
	--error-color: #dc3545;
	--success-color: #28a745;
	--input-height: 45px;
	--font-size: 20px;
	--label-gap: 12px;
	--row-gap: 12px;
	--tab-active-bg: #eee;     /* Light grey for active tab */
	--tab-text-color: #cb001b; /* Your red */
}

/* ============================================================= */
/*  Global Layout                                                */
/* ============================================================= */
body {
	font-family: Arial, sans-serif;
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100vh;
	margin: 0;
	background: var(--primary-bg);
	overscroll-behavior: none;
}

.container {
	background: var(--container-bg);
	padding: 15px;
	border-radius: 8px;
	box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
	width: 90%;
	max-width: 360px;
}

.hidden { display: none; }

/* ============================================================= */
/*  Header & Subtitle                                            */
/* ============================================================= */
.header {
	display: flex;
	justify-content: center;
	align-items: center;
	margin-bottom: 5px;
}
.header img { height: 50px; }
.header h1 { font-size: 28px; margin: 0; color: #000; }

.subtitle {
	font-size: 20px;
	text-align: center;
	color: #000;
	margin: 5px 0 var(--row-gap);
}

/* ============================================================= */
/*  Form Elements – Labels, Inputs, Buttons                     */
/* ============================================================= */
label {
	font-size: 16px;
	color: #000;
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin: 0 !important;
	padding: 0 0 var(--label-gap) 0 !important;
	gap: 8px;
	line-height: 1.3;
	min-height: 24px;
}

select,
input {
	width: 100%;
	padding: 8px;
	box-sizing: border-box;
	height: var(--input-height);
	font-size: var(--font-size);
	border: 1px solid var(--border-color);
	border-radius: 4px;
	color: #333;
	background: #fff;
	text-align: center;
	margin: 0;
}

/* Input-group */
.input-group {
	display: flex;
	align-items: center;
	gap: 4px;
	margin: 0 0 var(--row-gap) 0 !important;
}
.input-group input { flex: 1; }
.input-group button {
	width: 36px;
	height: var(--input-height);
	font-size: 24px;
	cursor: pointer;
	user-select: none;
	touch-action: manipulation;
	border: 1px solid var(--border-color);
	background: var(--container-bg);
	border-radius: 4px;
	color: var(--button-bg);
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	line-height: 1;
}

#mealTime {
	margin: 0 0 var(--row-gap) 0 !important;
}

/* ============================================================= */
/*  Meal Builder Icon                                            */
/* ============================================================= */
.meal-builder-icon {
	flex-shrink: 0;
	width: 36px;
	height: 24px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border-radius: 6px;
	transition: background 0.2s;
	margin-left: 4px;
}
.meal-builder-icon:hover { background: rgba(203, 0, 27, 0.1); }
.meal-builder-icon img {
	height: 28px;
	width: auto;
	vertical-align: middle;
}

/* ============================================================= */
/*  Buttons                                                      */
/* ============================================================= */
#logDoseButton {
	width: 120px;
	height: 120px;
	border-radius: 50%;
	background: var(--button-bg);
	color: #fff;
	font-size: 42px;
	font-weight: bold;
	border: none;
	cursor: pointer;
	touch-action: manipulation;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	margin: 15px auto;
	transition: background 0.3s;
}
#logDoseButton:hover { background: #a00015; }
#logDoseButton span.units { font-size: 18px; font-weight: normal; }

#exportButton,
#saveSettings {
	width: 100%;
	padding: 8px;
	color: #fff;
	border: none;
	cursor: pointer;
	border-radius: 4px;
	touch-action: manipulation;
	background: var(--button-bg);
}

/* ============================================================= */
/*  NAV & ADD TO MEAL BUTTONS — NOW IDENTICAL                    */
/* ============================================================= */
.nav-links {
	display: flex;
	justify-content: space-around;
	margin-bottom: var(--row-gap);
}
.nav-links button,
#addToMealButton {  /* ← NEW: Matches nav buttons */
	padding: 8px;
	cursor: pointer;
	touch-action: manipulation;
	border: 1px solid var(--border-color);
	background: var(--container-bg);
	border-radius: 4px;
	color: var(--button-bg);
	font-size: 14px;
	font-weight: normal;
	min-width: 100px;
	flex: 1;
	margin: 0 4px;
}
.nav-links button:hover,
#addToMealButton:hover {
	background: #f0f0f0;
}

/* ============================================================= */
/*  Modal & Navigation                                           */
/* ============================================================= */
.modal {
	display: none;
	position: fixed;
	z-index: 1;
	left: 0; top: 0;
	width: 100%; height: 100%;
	background: rgba(0,0,0,0.4);
	justify-content: center;
	align-items: center;
}
.modal-content {
	background: var(--container-bg);
	margin: auto;
	padding: 15px;
	border: 1px solid var(--border-color);
	width: 90%;
	max-width: 360px;
	border-radius: 8px;
	max-height: 80vh;
	overflow-y: auto;
	position: relative;
}
.close {
	position: absolute;
	top: 8px; right: 8px;
	font-size: 20px;
	cursor: pointer;
	touch-action: manipulation;
}

/* Accordion */
.accordion {
	background: #eee;
	color: #444;
	cursor: pointer;
	padding: 8px;
	width: 100%;
	text-align: left;
	border: none;
	border-radius: 4px;
	margin-bottom: 4px;
	font-size: 16px;
}
.active, .accordion:hover { background: #ccc; }
.panel {
	padding: 0 12px;
	background: var(--container-bg);
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.2s linear, visibility 0.2s linear;
	visibility: hidden;
}
.panel.active {
	visibility: visible;
	padding: 8px 12px;
}
.panel label { font-size: 14px; margin-bottom: 4px; display: block; }

/* ============================================================= */
/*  Messages & Misc                                              */
/* ============================================================= */
#errorMessage,
#successMessage,
#errorMessageSettings,
#clearMessage {
	margin-top: 8px;
	text-align: center;
	font-size: 14px;
}
#errorMessage,
#errorMessageSettings { color: var(--error-color); }
#successMessage,
#clearMessage { color: var(--success-color); }

.disclaimer-link {
	text-align: center;
	margin-top: 15px;
	font-size: 14px;
}
.disclaimer-link a {
	color: var(--button-bg);
	cursor: pointer;
	text-decoration: underline;
}

.copyright {
	text-align: center;
	font-size: 12px;
	color: #fff;
	margin-top: 15px;
}

.instructions {
	text-align: center;
	font-size: 12px;
	color: #000;
	margin-top: 5px;
}

/* ============================================================= */
/*  Meal Builder Tabs & Cart — NO GOLD, RED TEXT                 */
/* ============================================================= */
.meal-tabs {
	display: flex;
	margin: 10px 0 8px 0;
	border-bottom: 1px solid var(--border-color);
}
.tab-btn {
	flex: 1;
	padding: 10px 8px;
	background: transparent;
	border: none;
	cursor: pointer;
	font-size: 14px;
	color: #666;
	text-align: center;
	border-bottom: 3px solid transparent;
	transition: all 0.2s;
}
.tab-btn.active {
	background: var(--tab-active-bg);     /* Light grey */
	color: var(--tab-text-color);          /* Red */
	font-weight: bold;
	border-bottom: 3px solid var(--tab-text-color);
}
.tab-btn i { margin-right: 4px; }

.tab-content { 
	max-height: 40vh; 
	overflow-y: auto; 
	padding: 5px 0; 
}
#usdaSearch, #quickName, #quickCarbs {
	width: 100%;
	margin-bottom: 8px;
	padding: 8px;
	font-size: 16px;
	border: 1px solid var(--border-color);
	border-radius: 4px;
}
.food-results {
	max-height: 200px;
	overflow-y: auto;
	border: 1px solid var(--border-color);
	border-radius: 4px;
	background: #fafafa;
}
.food-item {
	padding: 10px;
	border-bottom: 1px solid #eee;
	cursor: pointer;
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.food-item:hover { background: #f0f0f0; }

.meal-cart { 
	margin-top: 20px; 
	border-top: 1px solid var(--border-color); 
	padding-top: 10px; 
}
#cartList { list-style: none; padding: 0; margin: 10px 0; }
.cart-item { 
	padding: 10px; 
	border: 1px solid var(--border-color); 
	border-radius: 4px; 
	margin-bottom: 8px; 
	background: #f9f9f9; 
}
.cart-item-header { 
	display: flex; 
	justify-content: space-between; 
	cursor: pointer; 
	font-weight: bold; 
}
.cart-item-details { 
	display: none; 
	margin-top: 8px; 
	padding: 8px; 
	background: #fff; 
	border-radius: 4px; 
	font-size: 14px; 
}
#submitMeal { 
	width: 100%; 
	background: var(--button-bg); 
	color: white; 
	padding: 10px; 
	border: none; 
	border-radius: 4px; 
	font-weight: bold; 
}

/* ============================================================= */
/*  Logs View                                                    */
/* ============================================================= */
#logsView { text-align: left; }
#calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.day { padding: 8px; text-align: center; border: 1px solid var(--border-color); cursor: pointer; font-size: 14px; }
.day:hover { background: #eee; }
.header { font-weight: bold; font-size: 14px; }

/* ============================================================= */
/*  FINAL SPACING: ALL LABEL → INPUT GAPS = 12px                 */
/* ============================================================= */
label:first-of-type {
	padding-top: 0 !important;
}
label:nth-of-type(n+2) {
	padding-top: var(--row-gap) !important;
}