/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.header-controls {
    display: flex;
    gap: 15px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    border: 2px solid #e0e6ed;
}

.btn-secondary:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

/* Main Content */
main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Sections */
section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.8rem;
    font-weight: 600;
}

/* Totals Section */
.totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.total-item {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 5px 20px;
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 15px;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease;
}

.total-item:hover {
    transform: translateY(-2px);
}

.nutrient {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1.1rem;
}

.current {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    text-align: center;
}

.target {
    font-size: 1.2rem;
    font-weight: 600;
    color: #6c757d;
    text-align: center;
}

.remaining {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    padding: 5px 10px;
    border-radius: 6px;
}

.remaining.positive {
    background: #d4edda;
    color: #155724;
}

.remaining.negative {
    background: #f8d7da;
    color: #721c24;
}

.remaining.zero {
    background: #fff3cd;
    color: #856404;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-input {
    padding: 12px 16px;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    font-size: 1rem;
    width: 300px;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    max-height: 70vh;
    overflow-y: auto;
    position: relative;
}

.food-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.food-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
}

.food-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.3s ease;
}

.food-table th.sortable:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* Sticky header styles for JavaScript implementation */
#stickyHeader {
    position: fixed !important;
    top: 0 !important;
    z-index: 1000 !important;
    background: white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    table-layout: fixed !important;
}

#stickyHeader th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    padding: 15px 12px !important;
    text-align: left !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2) !important;
    box-sizing: border-box !important;
}

.sort-indicator {
    font-size: 0.8rem;
    margin-left: 5px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.food-table th.sortable:hover .sort-indicator {
    opacity: 1;
}

.food-table th.sort-asc .sort-indicator::after {
    content: " ↑";
    opacity: 1;
}

.food-table th.sort-desc .sort-indicator::after {
    content: " ↓";
    opacity: 1;
}

.food-table td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.food-table tbody tr {
    transition: background-color 0.3s ease;
}

.food-table tbody tr:hover {
    background-color: #f8f9fa;
}

.food-table tbody tr:last-child td {
    border-bottom: none;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
}

/* Settings Grid */
.settings-grid {
    display: grid;
    gap: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.setting-item label {
    font-weight: 600;
    color: #2c3e50;
}

.setting-item input {
    padding: 8px 12px;
    border: 2px solid #e0e6ed;
    border-radius: 6px;
    font-size: 1rem;
    width: 120px;
    text-align: right;
}

.setting-item input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Quantity Form */
.quantity-form {
    display: grid;
    gap: 20px;
}

.form-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.form-group label {
    font-weight: 600;
    color: #2c3e50;
}

.form-group input,
.form-group select {
    padding: 8px 12px;
    border: 2px solid #e0e6ed;
    border-radius: 6px;
    font-size: 1rem;
    width: 120px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#baseUnitDisplay {
    font-weight: 600;
    color: #667eea;
    background: #e3f2fd;
    padding: 8px 12px;
    border-radius: 6px;
}

/* Food Form */
.food-form {
    display: grid;
    gap: 15px;
}

.food-form .form-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.food-form .form-group label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 120px;
}

.food-form .form-group input {
    padding: 8px 12px;
    border: 2px solid #e0e6ed;
    border-radius: 6px;
    font-size: 1rem;
    width: 150px;
}

.food-form .form-group select {
    padding: 8px 12px;
    border: 2px solid #e0e6ed;
    border-radius: 6px;
    font-size: 1rem;
    width: 150px;
}

.food-form .form-group input:focus,
.food-form .form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Import Form */
.import-form {
    text-align: center;
    padding: 20px;
}

.file-input {
    margin: 15px 0;
    padding: 10px;
    border: 2px dashed #667eea;
    border-radius: 8px;
    background: #f8f9fa;
    width: 100%;
    cursor: pointer;
}

.help-text {
    color: #6c757d;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.action-buttons .btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    min-width: auto;
}

/* Summary Section */
.summary-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-top: 30px;
}

.summary-content {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 2px solid #e9ecef;
}

.summary-text {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #2c3e50;
    white-space: pre-line;
    background: white;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.summary-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.summary-controls .btn {
    font-size: 0.9rem;
    padding: 8px 16px;
}

/* Login Section */
.login-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.login-container {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.login-container h2 {
    color: #2c3e50;
    font-size: 2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.login-container p {
    color: #6c757d;
    font-size: 1.1rem;
    margin-bottom: 30px;
    line-height: 1.5;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.login-form input {
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1.1rem;
    text-align: center;
    transition: border-color 0.3s ease;
}

.login-form input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-note {
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
}

.welcome-user {
    color: #2c3e50;
    font-weight: 600;
    margin-right: 15px;
    font-size: 1rem;
}

/* Supplements Section */
.supplements-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.supplements-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.supplements-label {
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
}

.supplements-checkboxes {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.supplement-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #2c3e50;
    position: relative;
    padding-left: 35px;
}

.supplement-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #f8f9fa;
    border: 2px solid #667eea;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.supplement-checkbox:hover input ~ .checkmark {
    background-color: #e3f2fd;
    border-color: #5a6fd8;
}

.supplement-checkbox input:checked ~ .checkmark {
    background-color: #667eea;
    border-color: #667eea;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.supplement-checkbox input:checked ~ .checkmark:after {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .header-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
    }
    
    .totals-grid {
        grid-template-columns: 1fr;
    }
    
    .total-item {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 10px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .setting-item,
    .form-group {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .setting-item input,
    .form-group input,
    .form-group select {
        width: 100%;
    }
    
    .supplements-row {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .supplements-checkboxes {
        gap: 20px;
    }
    
    .supplement-checkbox {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .food-table {
        font-size: 0.9rem;
    }
    
    .food-table th,
    .food-table td {
        padding: 8px 6px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}
