/**
 * Standard Calculator for Diet & Fitness - Enhanced Styles
 * Brand Color: #379237
 * Version: 2.0.0 with Database Integration
 */

/* Reset and Base Styles */
.scdf-calculator-wrapper * {
    box-sizing: border-box;
}

.scdf-calculator-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
}

/* Header Styles */
.scdf-calculator-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #379237 0%, #4a9f4a 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(55, 146, 55, 0.2);
}

.scdf-calculator-title {
    margin: 0 0 10px 0;
    font-size: 2.2em;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.scdf-calculator-description {
    margin: 0;
    font-size: 1.1em;
    opacity: 0.95;
    font-weight: 300;
}

/* Main Layout */
.scdf-calculator-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

/* Container Styles */
.scdf-container {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.scdf-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.12);
}

.scdf-container-title {
    margin: 0 0 20px 0;
    font-size: 1.4em;
    font-weight: 600;
    color: #379237;
    border-bottom: 2px solid #379237;
    padding-bottom: 8px;
}

/* Results Container Special Styling */
.scdf-results-container {
    background: linear-gradient(135deg, #f8fdf8 0%, #f0f8f0 100%);
    border: 2px solid #379237;
}

/* Mode Toggle */
.scdf-mode-toggle {
    display: flex;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #379237;
}

.scdf-mode-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: #fff;
    color: #379237;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.scdf-mode-btn:hover {
    background: #f0f8f0;
}

.scdf-mode-btn.scdf-mode-active {
    background: #379237;
    color: white;
}

.scdf-mode-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Food Search */
.scdf-food-search-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.scdf-search-wrapper {
    position: relative;
}

.scdf-search-wrapper input {
    padding-right: 40px;
}

.scdf-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.scdf-suggestions-dropdown {
    position: relative;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-top: 8px;
    margin-bottom: 16px;
}

.scdf-suggestion-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.scdf-suggestion-item:hover,
.scdf-suggestion-item.scdf-highlighted {
    background: #f0f8f0;
}

.scdf-suggestion-item:last-child {
    border-bottom: none;
}

.scdf-suggestion-name {
    font-weight: 600;
    color: #379237;
    margin-bottom: 4px;
}

.scdf-suggestion-info {
    font-size: 0.9em;
    color: #666;
}

/* Selected Food Display */
.scdf-selected-food {
    background: #f8fdf8;
    border: 2px solid #379237;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.scdf-food-details h4 {
    margin: 0 0 8px 0;
    color: #379237;
    font-size: 1.2em;
}

.scdf-food-details p {
    margin: 0 0 12px 0;
    color: #666;
    font-size: 0.9em;
}

.scdf-nutrition-info {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.scdf-nutrition-info span {
    background: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    border: 1px solid #379237;
    color: #379237;
}

/* Quantity Controls */
.scdf-quantity-input {
    margin-bottom: 15px;
}

.scdf-quantity-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.scdf-quantity-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.scdf-qty-btn {
    width: 36px;
    height: 36px;
    border: 2px solid #379237;
    background: white;
    color: #379237;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.scdf-qty-btn:hover {
    background: #379237;
    color: white;
}

#scdf-quantity {
    width: 80px;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
}

#scdf-serving-info {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
}

/* Input Form Styles */
.scdf-input-form {
    margin-bottom: 25px;
}

.scdf-input-group {
    margin-bottom: 15px;
}

.scdf-input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
    font-size: 0.95em;
}

.scdf-input-group input,
.scdf-input-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #fafafa;
}

.scdf-input-group input:focus,
.scdf-input-group select:focus {
    outline: none;
    border-color: #379237;
    box-shadow: 0 0 0 3px rgba(55, 146, 55, 0.1);
    background: #fff;
}

.scdf-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Button Styles */
.scdf-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.scdf-btn-primary {
    background: #379237;
    color: white;
    box-shadow: 0 4px 15px rgba(55, 146, 55, 0.3);
}

.scdf-btn-primary:hover {
    background: #2d7a2d;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(55, 146, 55, 0.4);
}

.scdf-btn-secondary {
    background: #6c757d;
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.scdf-btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}

.scdf-btn-danger {
    background: #f44336;
    color: white;
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
}

.scdf-btn-danger:hover {
    background: #d32f2f;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
}

.scdf-btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

/* Food List Styles */
.scdf-entries-list h4 {
    margin: 20px 0 10px 0;
    color: #379237;
    font-weight: 600;
}

.scdf-food-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.scdf-food-item {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.scdf-food-item:hover {
    background: #f0f0f0;
}

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

.scdf-food-name {
    font-weight: 600;
    color: #379237;
    margin-bottom: 4px;
}

.scdf-food-macros {
    font-size: 0.9em;
    color: #666;
}

.scdf-food-quantity {
    font-size: 0.85em;
    color: #999;
    font-style: italic;
}

.scdf-remove-btn {
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.scdf-remove-btn:hover {
    background: #cc0000;
}

/* Results Styles */
.scdf-results-content {
    text-align: center;
}

.scdf-result-item {
    margin-bottom: 20px;
}

.scdf-calories-result {
    background: #379237;
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(55, 146, 55, 0.2);
}

.scdf-calories-result .scdf-result-label {
    display: block;
    font-size: 1.1em;
    margin-bottom: 5px;
    opacity: 0.9;
}

.scdf-calories-result .scdf-result-value {
    font-size: 2.2em;
    font-weight: 700;
}

/* Enhanced Macros Grid */
.scdf-macros-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.scdf-macro-item {
    background: white;
    border: 2px solid #379237;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: transform 0.2s ease;
}

.scdf-macro-item:hover {
    transform: translateY(-2px);
}

.scdf-macro-header {
    font-weight: 600;
    color: #379237;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.scdf-macro-values {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.scdf-macro-values span:first-child {
    font-size: 1.3em;
    font-weight: 700;
    color: #333;
}

.scdf-macro-values span:last-child {
    font-size: 0.9em;
    color: #666;
}

/* Macro Progress Bars */
.scdf-macro-bar {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.scdf-macro-fill {
    height: 100%;
    background: #379237;
    transition: width 0.5s ease;
    border-radius: 3px;
}

/* Additional Info */
.scdf-additional-info {
    background: white;
    border: 1px solid #379237;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.scdf-info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.scdf-info-row:last-child {
    margin-bottom: 0;
}

.scdf-info-label {
    font-weight: 600;
    color: #379237;
}

/* Action Buttons */
.scdf-action-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Quick Add Section */
.scdf-quick-add {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #dee2e6;
}

.scdf-quick-add h4 {
    margin: 0 0 15px 0;
    color: #379237;
    text-align: center;
}

.scdf-quick-foods {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.scdf-quick-food-btn {
    padding: 8px 16px;
    background: white;
    border: 2px solid #379237;
    color: #379237;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scdf-quick-food-btn:hover {
    background: #379237;
    color: white;
}

/* Modal Styles */
.scdf-modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.scdf-modal-content {
    background-color: #fff;
    margin: 5% auto;
    border-radius: 12px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.scdf-modal-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9f9;
    border-radius: 12px 12px 0 0;
}

.scdf-modal-header h3 {
    margin: 0;
    color: #379237;
}

.scdf-modal-close {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.scdf-modal-close:hover {
    color: #000;
}

.scdf-modal-body {
    padding: 20px;
}

/* Export Styles */
.scdf-export-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.scdf-export-content {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.9em;
    white-space: pre-wrap;
}

/* Responsive Design */
@media (max-width: 768px) {
    .scdf-calculator-main {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .scdf-calculator-title {
        font-size: 1.8em;
    }
    
    .scdf-input-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .scdf-macros-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .scdf-container {
        padding: 20px;
    }
    
    .scdf-food-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .scdf-remove-btn {
        align-self: flex-end;
    }
    
    .scdf-food-search-container {
        grid-template-columns: 1fr;
    }
    
    .scdf-nutrition-info {
        flex-direction: column;
        gap: 8px;
    }
    
    .scdf-quantity-controls {
        justify-content: center;
    }
    
    .scdf-action-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .scdf-calculator-wrapper {
        padding: 15px;
    }
    
    .scdf-calculator-header {
        padding: 15px;
    }
    
    .scdf-calculator-title {
        font-size: 1.5em;
    }
    
    .scdf-calculator-description {
        font-size: 1em;
    }
    
    .scdf-container {
        padding: 15px;
    }
    
    .scdf-calories-result .scdf-result-value {
        font-size: 1.8em;
    }
    
    .scdf-mode-toggle {
        flex-direction: column;
    }
    
    .scdf-modal-content {
        width: 95%;
        margin: 2% auto;
    }
}

/* Animation for adding items */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scdf-food-item {
    animation: slideIn 0.3s ease;
}

/* Loading state */
.scdf-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Empty state */
.scdf-empty-state {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
}

/* Accessibility improvements */
.scdf-btn:focus,
.scdf-input-group input:focus,
.scdf-input-group select:focus {
    outline: 2px solid #379237;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .scdf-calculator-wrapper {
        box-shadow: none;
    }
    
    .scdf-btn,
    .scdf-mode-toggle,
    .scdf-input-form,
    .scdf-action-buttons {
        display: none;
    }
    
    .scdf-container {
        break-inside: avoid;
    }
    
    .scdf-calculator-main {
        grid-template-columns: 1fr;
    }
}


/* Added Foods Section in Results */
.scdf-added-foods-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8fdf8;
    border-radius: 8px;
    border: 1px solid #e0f0e0;
}

.scdf-added-foods-section h4 {
    margin: 0 0 12px 0;
    color: #379237;
    font-size: 1.1em;
    font-weight: 600;
}

.scdf-added-foods-section .scdf-food-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.scdf-added-foods-section .scdf-food-list:empty::after {
    content: "No foods added yet. Start by searching for foods or adding manual entries.";
    color: #999;
    font-style: italic;
    display: block;
    padding: 10px 0;
    text-align: center;
}

.scdf-added-foods-section .scdf-food-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.scdf-added-foods-section .scdf-food-item:hover {
    border-color: #379237;
    box-shadow: 0 2px 8px rgba(55, 146, 55, 0.1);
}

.scdf-added-foods-section .scdf-food-info {
    flex: 1;
}

.scdf-added-foods-section .scdf-food-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.scdf-added-foods-section .scdf-food-details {
    font-size: 0.85em;
    color: #666;
}

.scdf-added-foods-section .scdf-remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scdf-added-foods-section .scdf-remove-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}
