/* Meal History Tab Styling */

.meal-history-controls {
    margin: 20px 0;
    text-align: center;
}

/* Make the meal history table fit without scrolling */
.meal-history-data {
    margin: 20px 0;
    overflow: hidden; /* Remove horizontal scrollbar */
}

.meal-history-table {
    width: 100%;
    max-width: 100%; /* Ensure table doesn't exceed container */
    border-collapse: collapse;
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(255,255,255,0.1);
    table-layout: fixed; /* Fixed layout for better control */
}

.refresh-btn {
    background: #28a745;
    color: #ffffff;
    border: 2px solid #28a745;
    border-radius: 5px;
    padding: 10px 20px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.refresh-btn:hover {
    background: #218838;
    border-color: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

.refresh-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.loading-message {
    text-align: center;
    color: #cccccc;
    font-style: italic;
    padding: 20px;
}

.no-data-message {
    text-align: center;
    color: #cccccc;
    font-style: italic;
    padding: 40px 20px;
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 8px;
}

.meal-history-table th {
    background: #333333;
    color: #ffffff;
    padding: 12px 12px;
    text-align: left;
    font-weight: bold;
    border-bottom: 1px solid #555555;
    white-space: nowrap;
}

.meal-history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #333333;
    color: #ffffff;
    font-size: 0.9em;
    vertical-align: top;
}

.meal-history-table tr:hover {
    background: #2a2a2a;
}

.meal-history-table tr:last-child td {
    border-bottom: none;
}

/* Responsive table */
@media (max-width: 1400px) {
    .meal-history-table {
        font-size: 0.85em;
    }
    
    .meal-history-table th,
    .meal-history-table td {
        padding: 8px 6px;
    }
    
    .description-column {
        width: 28%; /* Slightly smaller description column */
    }
    
    .nutrition-column {
        width: 10%; /* Maintain larger nutrition columns */
    }
    
    .date-column {
        width: 12%; /* Maintain date column size */
    }
}

@media (max-width: 1200px) {
    .meal-history-table {
        font-size: 0.8em;
    }
    
    .meal-history-table th,
    .meal-history-table td {
        padding: 6px 4px;
    }
    
    .description-column {
        width: 25%; /* Smaller description column */
    }
    
    .nutrition-column {
        width: 10%; /* Maintain nutrition column size */
    }
    
    .action-column {
        width: 10%; /* Maintain action column size */
    }
    
    .date-column {
        width: 12%; /* Maintain date column size */
    }
}

@media (max-width: 992px) {
    .meal-history-table {
        font-size: 0.75em;
    }
    
    .meal-history-table th,
    .meal-history-table td {
        padding: 4px 2px;
    }
    
    .description-column {
        width: 22%; /* Smaller description column */
    }
    
    .nutrition-column {
        width: 10%; /* Maintain nutrition column size */
    }
    
    .action-column {
        width: 10%; /* Maintain action column size */
    }
    
    .date-column {
        width: 12%; /* Maintain date column size */
    }
}

/* Date column styling */
.date-column {
    white-space: nowrap;
    width: 12%; /* Increased from 10% */
}

/* Description column styling */
.description-column {
    width: 30%; /* Reduced from 35% to make room for other columns */
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.3;
    overflow-wrap: break-word;
}

/* Items column */
.items-column {
    text-align: center;
    width: 8%; /* Increased from 6% */
}

/* Nutrition columns */
.nutrition-column {
    text-align: right;
    width: 10%; /* Increased from 8% each for better visibility */
    white-space: nowrap;
    overflow: visible; /* Changed from hidden to visible */
    text-overflow: clip; /* Changed from ellipsis to clip */
}

/* Action column */
.action-column {
    text-align: center;
    width: 10%; /* Increased from 9% */
}

/* Details button */
.details-btn {
    background: #007bff;
    color: #ffffff;
    border: 2px solid #007bff;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.8em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.details-btn:hover {
    background: #0056b3;
    border-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.4);
}

.details-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

/* Date group header styling */
.date-group-header {
    background: #333333 !important;
    font-weight: bold;
}

.date-group-header:hover {
    background: #444444 !important;
}

.date-group-header td {
    border-bottom: 2px solid #555555;
}

/* Description group row styling */
.description-group-row {
    background: #2a2a2a;
}

.description-group-row:hover {
    background: #3a3a3a !important;
}

.description-group-row .description-column {
    padding-left: 20px; /* Reduced indent for better space usage */
}

/* Individual item row styling */
.item-row {
    background: #1a1a1a;
}

.item-row:hover {
    background: #2a2a2a !important;
}

.item-row .description-column {
    padding-left: 40px; /* Reduced indent for better space usage */
}

.item-row td {
    border-bottom: 1px solid #222222;
    font-size: 0.9em;
}

/* Item indent styling */
.item-indent {
    display: inline-block;
    width: 16px;
    margin-right: 8px;
}

/* Expand icon styling */
.expand-icon {
    display: inline-block;
    width: 16px;
    margin-right: 8px;
    font-size: 0.8em;
    transition: transform 0.2s ease;
}

/* Expand date button */
.expand-date-btn {
    background: #28a745;
    color: #ffffff;
    border: 2px solid #28a745;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.7em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.expand-date-btn:hover {
    background: #218838;
    border-color: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

.expand-date-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

/* Meal Detail Overlay */
.meal-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    box-sizing: border-box;
}

.meal-detail-content {
    background: #1a1a1a;
    border: 2px solid #ffffff;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    width: 800px;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

.meal-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333333;
    background: #333333;
}

.meal-detail-header h3 {
    margin: 0;
    color: #ffffff;
}

.close-detail-overlay {
    color: #ffffff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-detail-overlay:hover {
    color: #ff6b6b;
}

.meal-detail-info {
    padding: 20px;
    border-bottom: 1px solid #333333;
    background: #2a2a2a;
}

.meal-detail-info p {
    margin: 5px 0;
    color: #ffffff;
}

.meal-detail-table-container {
    padding: 20px;
    overflow-x: auto;
}

.meal-detail-table {
    width: 100%;
    border-collapse: collapse;
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 8px;
    overflow: hidden;
}

.meal-detail-table th {
    background: #333333;
    color: #ffffff;
    padding: 12px 8px;
    text-align: left;
    font-weight: bold;
    border-bottom: 1px solid #555555;
}

.meal-detail-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #333333;
    color: #ffffff;
    font-size: 0.9em;
}

.meal-detail-table tr:hover {
    background: #2a2a2a;
}

.meal-detail-table tr:last-child td {
    border-bottom: none;
}

.totals-row {
    background: #333333 !important;
    font-weight: bold;
}

.totals-row td {
    border-top: 2px solid #555555;
}

/* Responsive overlay */
@media (max-width: 768px) {
    .meal-detail-content {
        width: 95%;
        max-height: 95%;
    }
    
    .meal-detail-table {
        font-size: 0.8em;
    }
    
    .meal-detail-table th,
    .meal-detail-table td {
        padding: 8px 4px;
    }
}
