*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

nav {
    background-color: #2c3e50;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
}

nav a {
    color: #ecf0f1;
    text-decoration: none;
    font-weight: 500;
}

.nav-link {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
}

.nav-link.active {
    background-color: #3498db;
    color: white;
}

nav a:hover {
    color: #3498db;
}

.nav-link.active:hover {
    color: white;
}

nav .nav-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* User dropdown menu */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-trigger {
    background: none;
    border: none;
    border-radius: 4px;
    color: #ecf0f1;
    cursor: pointer;
    font-size: 1.4rem;
    padding: 0.15rem 0.4rem;
    line-height: 1;
}

.nav-dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-dropdown-trigger:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.25rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0.75rem;
    min-width: 180px;
    z-index: 100;
}

.nav-dropdown:focus-within .nav-dropdown-menu {
    display: block;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-email {
    display: block;
    color: #333;
    font-size: 0.85rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    word-break: break-all;
}

h1, h2 {
    color: #2c3e50;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check input[type="checkbox"] {
    width: auto;
}

.form-check label {
    display: inline;
    margin-bottom: 0;
}

.error {
    color: #e74c3c;
    margin-bottom: 1rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Water Tracker */
.water-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.water-header h1 {
    margin: 0;
}

.btn-settings {
    color: #666;
    font-size: 0.9rem;
}

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

.progress-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    margin: 1rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: conic-gradient(
        #3498db calc(var(--percentage, 0) * 1%),
        #ecf0f1 calc(var(--percentage, 0) * 1%)
    );
    position: relative;
}

.progress-circle-inner {
    width: 170px;
    height: 170px;
    border-radius: 50%;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.progress-amount {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
}

.progress-divider {
    font-size: 0.85rem;
    color: #999;
}

.progress-percent {
    font-size: 1.1rem;
    font-weight: 600;
    color: #3498db;
    margin-top: 0.25rem;
}

.water-actions {
    margin: 1.5rem 0;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.25rem;
}

.water-custom {
    margin: 1rem 0;
}

.custom-amount-row {
    display: flex;
    gap: 0.5rem;
    max-width: 250px;
    margin: 0 auto 0.75rem;
}

.custom-amount-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    text-align: center;
}

.quick-amounts {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-quick {
    background: #ecf0f1;
    color: #2c3e50;
    padding: 0.4rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-quick:hover {
    background: #d5dbdb;
}

.water-log {
    margin-top: 1.5rem;
    text-align: left;
}

.water-log h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.water-log-entry {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.water-log-time {
    color: #999;
}

/* Food Tracker */
.food-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.food-header h1 {
    margin: 0;
}

.food-actions-top {
    display: flex;
    gap: 0.5rem;
}

.food-section {
    margin-top: 1.5rem;
}

.search-bar {
    margin-bottom: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.product-grid {
    display: grid;
    gap: 0.5rem;
}

.product-card {
    padding: 0.75rem;
    border: 1px solid #eee;
    border-radius: 4px;
}

.product-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.product-brand {
    color: #666;
    font-weight: 400;
}

.product-nutrition {
    font-size: 0.85rem;
    color: #666;
}

.product-nutrition .kcal {
    font-weight: 500;
    color: #e67e22;
    margin-right: 0.5rem;
}

.product-nutrition .per-amount {
    color: #999;
    margin-left: 0.5rem;
}

.empty-message {
    color: #999;
    text-align: center;
    padding: 2rem 0;
}

/* Day circles */
.day-circles {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 0 1rem;
}

.day-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem 0.6rem;
    border: 2px solid #eee;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    min-width: 48px;
}

.day-circle:hover {
    border-color: #3498db;
}

.day-circle.today {
    border-color: #3498db;
}

.day-circle.selected {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.day-circle .day-name {
    font-size: 0.7rem;
    text-transform: uppercase;
}

.day-circle .day-num {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Food add button */
.food-add-btn {
    text-align: center;
    margin-bottom: 1rem;
}

/* Food log entries */
.food-log-list {
    margin-bottom: 1rem;
}

.food-log-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 0.5rem;
}

.food-log-info {
    flex: 1;
}

.food-log-name {
    font-weight: 500;
    display: block;
}

.food-log-brand {
    color: #666;
    font-weight: 400;
}

.food-log-grams-wrap {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.food-log-grams {
    font-size: 0.85rem;
    color: #999;
}

.btn-grams-edit {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: #bbb;
    padding: 0 0.15rem;
    line-height: 1;
}

.btn-grams-edit:hover {
    color: #666;
}

.food-log-nutrition {
    text-align: right;
    font-size: 0.85rem;
}

.food-log-nutrition .kcal {
    font-weight: 500;
    color: #e67e22;
    display: block;
}

.food-log-nutrition .macros {
    color: #666;
}

.food-log-time {
    font-size: 0.8rem;
    color: #999;
    min-width: 40px;
    text-align: right;
}

/* Food summary */
.food-summary {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid #eee;
}

.food-summary h3 {
    margin: 0 0 0.5rem;
    color: #2c3e50;
}

.nutrition-table {
    width: 100%;
    border-collapse: collapse;
}

.nutrition-table td {
    padding: 0.3rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.nutrition-value {
    text-align: right;
    font-weight: 500;
}

/* Add food modal */
.modal-content {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fafafa;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    margin: 0;
}

.btn-close {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

.add-food-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 0.5rem;
}

.add-food-info {
    flex: 1;
}

.add-food-name {
    font-weight: 500;
    display: block;
}

.add-food-meta {
    font-size: 0.8rem;
    color: #999;
}

.add-food-form {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.grams-input {
    width: 60px;
    padding: 0.3rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
}

.success-message {
    color: #27ae60;
    margin-bottom: 0.5rem;
}

/* Ingredient row in recipe form */
.ingredient-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.ingredient-row .ingredient-select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    min-width: 0;
}

.ingredient-row .ingredient-grams {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.btn-add-ingredient {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Ingredient search */
.ingredient-search-block {
    position: relative;
}

.ingredient-search-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    min-width: 0;
}

.ingredient-search-results {
    border: 1px solid #eee;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.25rem;
}

.ingredient-search-results:empty {
    display: none;
}

.ingredient-search-item {
    padding: 0.5rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ingredient-search-item:last-child {
    border-bottom: none;
}

.ingredient-search-item:hover {
    background: #f0f7ff;
}

.ingredient-search-name {
    font-weight: 500;
}

.ingredient-search-meta {
    font-size: 0.8rem;
    color: #999;
}

.ingredient-added-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.ingredient-added-name {
    flex: 1;
    font-weight: 500;
}

.ingredient-added-grams {
    color: #666;
    font-size: 0.9rem;
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
}

.form-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

/* Mobile responsive */
@media (max-width: 600px) {
    nav {
        flex-wrap: wrap;
        padding: 0.5rem;
        width: 100%;
    }

    .nav-links {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .nav-right {
        justify-content: flex-end;
    }

    .day-circles {
        gap: 0.35rem;
    }

    .day-circle {
        min-width: 40px;
    }
}
