* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 12px;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    padding: 40px;
    backdrop-filter: blur(10px);
}

h1 {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2.5rem;
    color: #4a5568;
    font-weight: 300;
}

.calories-banner {
    text-align: center;
    background: linear-gradient(135deg, #FF6B6B, #4ECDC4);
    color: white;
    padding: 30px 20px;
    border-radius: 6px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.3);
    transition: transform 0.3s ease;
}

.calories-banner:hover {
    transform: translateY(-5px);
}

.calories-number {
    font-size: 4rem;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.calories-text {
    font-size: 1.3rem;
    opacity: 0.9;
}

.calories-text-goal {
    font-size: 0.9rem;
    color: #fff;
}

.calories-text-alkaline {
    font-size: 0.9rem;
    color: #cecece;
    font-weight: 700;
}

.date-display {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 30px;
    color: #4a5568;
    font-weight: 500;
}

.food-search-container {
    position: relative;
    z-index: 1001; /* Higher than other elements */
}
        
.food-search-input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: white;
    outline: none;       
}

.food-search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.food-search-input::placeholder {
    color: #999;
}

/* Loading indicator */
.search-loading {
    position: absolute;
    right: 15px;
    top: 30%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.search-loading.show {
    display: block;
}
        
@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Search Results Overlay */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    margin-top: 5px;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

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

.search-result-item:hover,
.search-result-item.highlighted {
    background-color: #f8f9ff;
}

.food-log-section {
    max-width: 800px;
    margin: 0 auto;
}

.section-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.food-cards-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.food-card {
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.food-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
    padding: 16px;
    cursor: pointer;
    display: flex;
    justify-content: between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
}

.card-header:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.card-main-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.food-name-time {
    flex: 1;
}

.food-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.card-header .food-name {
    color: #fff;
}

.food-time {
    font-size: 13px;
    opacity: 0.9;
}

.calories-display {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-align: right;
}

.expand-icon {
    margin-left: 12px;
    font-size: 14px;
    transition: transform 0.3s ease;
    opacity: 0.8;
}

.card-details {
    display: none;
}

.card-details.expanded {
  display: block;
}

.card-header-toggle .expand-icon {
  transition: transform 0.3s ease;
}

.card-header-toggle.expanded .expand-icon {
  transform: rotate(180deg);
}

.details-content {
    padding: 20px;
}

.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.nutrition-item {
    text-align: center;
    padding: 12px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nutrition-label {
    font-size: 12px;
    color: #666;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.nutrition-value {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete {
    background: #ff4757;
    color: white;
}

.btn-delete:hover {
    background: #ff3838;
}

.btn-edit {
    background: #5352ed;
    color: white;
}

.btn-edit:hover {
    background: #4834d4;
}

.btn-copy {
    background: #2ed573;
    color: white;
}

.btn-copy:hover {
    background: #1dd1a1;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.add-food-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.2s ease;
}

.add-food-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-1px);
}

.food-details {
    font-size: 13px;
    color: #666;
}

.food-calories {
    font-weight: 600;
    color: #667eea;
    font-size: 14px;
}

.no-results {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.add-food-section {
    background: white;
    padding: 30px;
    border-radius: 6px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.add-food-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #4a5568;
    text-align: center;
}

.add-food-form {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 15px;
    align-items: end;
}

.display-none {
  display: none;
}

.display-block {
  display: block;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

label {
    margin-bottom: 5px;
    font-weight: 600;
    color: #4a5568;
}

#gramAmount {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    min-width: 0;
    box-sizing: border-box;
    outline: none;
}

#gramAmount:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#gramAmount::placeholder {
    color: #999;
}

.add-btn {
    padding: 17px 25px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    height: fit-content;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.cancel-btn {
    padding: 17px 25px;
    background: linear-gradient(135deg, #757575, #616161);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    height: fit-content;
}

.cancel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.food-table-section {
    background: white;
    border-radius: 6px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.table-title {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
}

.food-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.food-table th,
.food-table td {
    padding: 15px 10px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.food-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
}

.food-table tr:hover {
    background: #f7fafc;
}

.delete-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s ease;
}

.delete-btn:hover {
    background: #e55656;
}

.calendar-section {
    background: white;
    border-radius: 6px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-top: 30px;
}

.calendar-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendar-nav {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.3s ease;
}

.calendar-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.calendar-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e2e8f0;
}

.calendar-day-header {
    background: #f8fafc;
    padding: 15px 5px;
    text-align: center;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
}

.calendar-day {
    background: white;
    padding: 15px 5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.calendar-day:hover {
    background: #f7fafc;
}

.calendar-day.other-month {
    color: #cbd5e0;
    background: #f8fafc;
}

.calendar-day.today {
    background: #667eea;
    /*color: white;*/
    font-weight: bold;
}

.calendar-day.selected {
    background: #4CAF50;
    color: white;
    font-weight: bold;
}

.calendar-day.has-data {
    background: #e6fffa;
    border: 2px solid #4ECDC4;
}

.calendar-day.has-data.selected {
    background: #4CAF50;
    border-color: #45a049;
}

.day-calories {
    font-size: 0.7rem;
    margin-top: 2px;
    opacity: 0.8;
}

.nutrition-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 6px;
}

.nutrition-item {
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nutrition-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #4a5568;
}

.nutrition-label {
    font-size: 0.8rem;
    color: #718096;
    margin-top: 2px;
}

.hidden-column {
    display: none;
}

.muted {
    color: #ccc;
}

@media (max-width: 768px) {
    .container {
        margin: 0px;
        padding: 15px;
    }

    .calories-number {
        font-size: 3rem;
    }

    .add-food-form {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .food-table {
        font-size: 0.8rem;
        min-width: 650px;
    }

    .food-table th,
    .food-table td {
        padding: 8px 5px;
        white-space: nowrap;
    }

    .table-wrapper {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    /* Optional: Add a subtle shadow to indicate scrollability */
    .table-wrapper::-webkit-scrollbar {
        height: 6px;
    }

    .table-wrapper::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }
    
    .table-wrapper::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }

    h1 {
        font-size: 2rem;
    }

    .card-header {
        padding: 14px;
    }

    .food-name {
        font-size: 15px;
    }

    .calories-display {
        font-size: 16px;
    }

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

    .details-content {
        padding: 16px;
    }
}
