/* Evalus Specific Styles - style.css?v=3.0 */

/* Inherit global variables and base styles */
@import url('../../css/styleglobal.css');

/* Body specific to the tool page */
body.tool-body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Manrope', 'Poppins', sans-serif; /* Prioritize Manrope for consistency */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.evalus-tool-container {
    width: 100%;
    max-width: 1400px; /* Max width for the tool layout */
    margin: 0 auto;
    padding: 20px;
    flex-grow: 1; /* Allow container to grow */
    display: flex;
    flex-direction: column;
}

/* Header */
.evalus-header {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space out items */
    padding-bottom: 15px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--sidebar-link-hover-bg); /* Subtle separator */
}

.evalus-header h1 {
    font-size: 1.8em;
    font-weight: 600;
    color: var(--text-color);
    margin: 0; /* Remove default margin */
    display: flex;
    align-items: center;
    gap: 10px;
}

.evalus-header .back-button {
    min-width: auto; /* Override global style if needed */
    padding: 8px 15px;
    font-size: 0.9em;
}

.evalus-header .icon {
    color: var(--primary-btn-bg); /* Use theme color */
    font-size: 0.9em; /* Slightly smaller icon in title */
}


/* View Switcher Tabs */
.view-switcher-tabs {
    display: flex;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--sidebar-link-hover-bg);
}

.tab-button {
    padding: 12px 20px;
    cursor: pointer;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent; /* Space for active indicator */
    color: var(--text-muted-color);
    font-size: 1em;
    font-weight: 500;
    transition: color 0.3s ease, border-bottom-color 0.3s ease;
    margin-bottom: -2px; /* Overlap the container border */
    display: flex;
    align-items: center;
    gap: 8px;
}
.tab-button .icon {
    font-size: 1.1em;
}

.tab-button:hover {
    color: var(--text-color);
}

.tab-button.active {
    color: var(--primary-btn-bg); /* Use theme color for active tab */
    border-bottom-color: var(--primary-btn-bg);
    font-weight: 600;
}

/* Main Content Layout */
.evalus-main-content {
    display: flex;
    gap: 25px; /* Space between columns */
    flex-grow: 1;
}

.input-column,
.results-column {
    flex: 1; /* Each column takes half the space */
    display: flex;
    flex-direction: column;
    gap: 20px; /* Space between cards in a column */
    min-width: 0; /* Prevent flexbox overflow issues */
}

/* Sections within columns (controlled by JS) */
.view-section {
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 20px; /* Consistent spacing */
}
.view-section.active {
    display: flex; /* Show active sections */
}


/* Card adjustments */
.card {
    background-color: var(--card-bg);
    border-radius: 10px; /* Slightly softer radius */
    padding: 20px;
    box-shadow: var(--card-shadow);
    transition: background-color 0.5s ease, box-shadow 0.5s ease;
    width: 100%; /* Ensure cards fill column */
}

.card h2 {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--sidebar-link-hover-bg);
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card h2 .icon {
     color: var(--primary-btn-bg); /* Theme color for icons */
     font-size: 1.1em;
}

/* Form Grid adjustments */
.form-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* Adjust minmax for tool density */
    gap: 15px; /* Slightly tighter gap */
}

.form-group label {
    font-size: 0.85em; /* Slightly smaller labels */
    margin-bottom: 5px;
}

/* Input/Select styling */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--sidebar-link-hover-bg); /* Use a subtle border */
    border-radius: 6px;
    background-color: var(--bg-color); /* Match background */
    color: var(--text-color);
    font-size: 0.9em;
    transition: border-color 0.3s ease, background-color 0.5s ease, color 0.5s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-btn-bg); /* Highlight focus */
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1); /* Subtle focus ring */
    body.dark-mode & {
         box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
    }
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.full-width-button {
    width: 100%;
    margin-top: 15px;
}

.action-buttons-grouped {
    display: flex;
    gap: 10px;
    justify-content: center; /* Or flex-end, flex-start */
    margin-top: 15px;
}
.action-buttons-grouped .action-button {
    flex: 1; /* Make buttons share space */
}
.action-buttons-grouped .action-button .icon {
    margin-right: 5px;
}

/* Danger button specific style */
.action-button.danger {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}
body.dark-mode .action-button.danger {
     background-color: #a12c34;
     border-color: #a12c34;
}
.action-button.danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
     body.dark-mode & {
         background-color: #8b232b;
         border-color: #8b232b;
     }
}


/* Results Section Specifics */
.results-section p {
    margin-bottom: 8px;
    line-height: 1.5;
    font-size: 0.95em;
}
.results-section strong {
    font-weight: 600;
    color: var(--text-color);
}
.highlight {
    font-weight: 600;
    color: var(--primary-btn-bg); /* Theme color for results */
    padding: 2px 4px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    body.dark-mode & {
        background-color: rgba(255, 255, 255, 0.1);
    }
}
.highlight.large {
    font-size: 1.1em;
}

.bmr-results, .final-macros, .diagnosis-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--sidebar-link-hover-bg);
}

.tee-result, .final-goal-display {
    margin-top: 15px;
    font-size: 1.1em;
    font-weight: 600;
}

/* Styles for Formula Select Container (Replaces old .inline-select) */
/* Specificity increased using ID */
#results-base .formula-select-container {
    display: flex;
    align-items: center; /* Vertically align label and select */
    justify-content: flex-start; /* Align items to the left */
    gap: 10px; /* Space between label and select */
    margin-top: 15px;
    margin-bottom: 15px; /* Increased bottom margin for spacing */
    padding: 0; /* Remove vertical padding */
    /* Removed border-top and border-bottom */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

#results-base .formula-select-container label {
    display: flex; /* Use flex to align icon and text */
    align-items: center;
    gap: 8px; /* Space between icon and text */
    margin-bottom: 0; /* Override default form-group label margin */
    white-space: nowrap;
    font-weight: 500;
    font-size: 0.95em;
    color: var(--text-muted-color);
}

#results-base .formula-select-container label .icon {
    color: var(--primary-btn-bg); /* Use theme color for icon */
    font-size: 1.1em; /* Adjust icon size if needed */
}

#results-base .formula-select-container select {
    /* Inherits base styles from general select */
    width: auto; /* Allow select to size based on content */
    min-width: 250px; /* Increased minimum width */
    flex-grow: 1; /* Allow to take remaining space */
    padding: 8px 12px; /* Consistent padding */
    font-size: 0.95em; /* Match label size */
    /* Ensure it uses the standard border, background, focus */
    border: 1px solid var(--sidebar-link-hover-bg);
    background-color: var(--bg-color);
    color: var(--text-color);
    border-radius: 6px;
    appearance: auto !important; /* Restore default browser appearance, add !important just in case */
    background-image: none !important; /* Remove custom SVG arrow from global style */
    padding-right: 12px !important; /* Restore default padding, removing space for custom arrow */
}

#results-base .formula-select-container select:focus {
    border-color: var(--primary-btn-bg);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
    body.dark-mode & {
         box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
    }
}

/* Macro Distribution Slider */
.slider-container {
    margin: 20px 0; /* Increased margin */
}
.slider-container label {
    display: block;
    margin-bottom: 12px; /* More space below label */
    font-size: 0.95em; /* Slightly larger label */
    font-weight: 500;
    color: var(--text-muted-color);
}

/* --- Custom Range Slider Styles --- */
/* Define a slider accent color variable */
:root {
    --slider-accent-color: #0077b6; /* Example blue color */
}
body.dark-mode {
    --slider-accent-color: #4cc9f0; /* Lighter blue for dark mode */
}

/* --- Revised Direct Slider Styling (Attempt 3) --- */
input[type="range"] {
    width: 100%;
    cursor: pointer;
    appearance: none;
    background: transparent; /* Ensure main element is transparent */
    outline: none;
    margin-bottom: 5px;
    padding: 0;
    /* Let height be determined by track/thumb */
}

/* Style the track for WebKit */
input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px; /* Actual track height */
    cursor: pointer;
    /* Use a solid background color for the track */
    background: var(--sidebar-link-hover-bg); /* Use the 'unfilled' color for the whole track */
    border-radius: 3px;
    border: none;
    /* Remove transition as background is static */
    /* transition: background 0.1s ease; */
}

/* Thumb (handle) Styles - WebKit */
input[type="range"]::-webkit-slider-thumb {
    appearance: none !important;
    width: 16px;
    height: 16px;
    background: #000000; /* Black background */
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid #333333; /* Dark gray border */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); /* Slightly stronger shadow for contrast */
    /* Ensure margin-top calculation is applied */
    margin-top: -5px !important; /* (6px - 16px) / 2 = -5px */
    transition: transform 0.1s ease;
}
input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.1);
}
input[type="range"]:focus::-webkit-slider-thumb {
     box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.5);
}


/* Style the track for Mozilla */
input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--sidebar-link-hover-bg); /* Use the 'unfilled' color for the whole track */
    border-radius: 3px;
    border: none;
}
/* Remove the progress fill style for Mozilla */
/* input[type="range"]::-moz-range-progress { ... } */


/* Thumb (handle) Styles - Mozilla */
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #000000; /* Black background */
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid #333333; /* Dark gray border */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); /* Slightly stronger shadow for contrast */
    transition: transform 0.1s ease;
    /* No margin-top needed for Firefox */
}
input[type="range"]:hover::-moz-range-thumb {
    transform: scale(1.1);
}
input[type="range"]:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.5);
}

/* Update slider background dynamically via JS */
/* Add this style update in your JS: sliderElement.style.setProperty('--slider-percentage', `${value}%`); */

/* --- End Custom Range Slider Styles --- */

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: var(--text-muted-color);
    padding: 0 5px; /* Align with slider thumbs */
}
.slider-value {
    display: none !important; /* Hide the CHO/Lipid percentage display */
    text-align: center;
    font-weight: 600;
    margin-top: 5px;
    color: var(--primary-btn-bg);
}

/* Macro Chart */
.macro-chart {
    display: flex;
    height: 25px; /* Adjust height */
    border-radius: 5px;
    overflow: hidden;
    margin: 15px 0;
    background-color: var(--sidebar-link-hover-bg); /* Background for the container */
}
.chart-bar {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8em;
    font-weight: 600;
    transition: width 0.5s ease;
    position: relative; /* For label positioning */
    overflow: hidden; /* Hide label if bar is too small */
}
.chart-label {
    padding: 0 5px;
    white-space: nowrap;
}
.protein-bar { background-color: #0077b6; } /* Blue */
.cho-bar { background-color: #fb8500; } /* Orange */
.lipid-bar { background-color: #8338ec; } /* Purple */

.total-check {
    text-align: right;
    font-weight: 600;
    margin-top: 10px;
    font-size: 0.9em;
}

/* Radio Button Group Styling */
.radio-group-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px; /* Row gap, Column gap */
    margin-top: 8px; /* Adjust spacing */
    margin-bottom: 5px;
}
.radio-option {
    display: flex;
    align-items: center;
    gap: 8px; /* Gap between custom radio and label */
    cursor: pointer; /* Make the whole option clickable */
}
.radio-option label {
    margin-bottom: 0;
    font-weight: 400;
    font-size: 0.95em; /* Slightly larger label */
    color: var(--text-color);
    cursor: pointer;
}

/* Hide default radio button */
.radio-option input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px; /* Custom size */
    height: 18px;
    border: 2px solid var(--text-muted-color);
    border-radius: 50%; /* Make it circular */
    cursor: pointer;
    position: relative;
    top: -1px; /* Fine-tune vertical alignment */
    transition: background-color 0.2s ease, border-color 0.2s ease;
    background-color: var(--bg-color);
    display: grid; /* Use grid to center the inner dot */
    place-content: center; /* Center the inner dot */
}

/* Inner dot for checked state */
.radio-option input[type="radio"]::before {
    content: "";
    width: 10px; /* Size of the inner dot */
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary-btn-text); /* Color of the dot */
    transform: scale(0); /* Hidden by default */
    transition: transform 0.1s ease-in-out;
}

/* Style for checked state */
.radio-option input[type="radio"]:checked {
    background-color: var(--primary-btn-bg); /* Use theme color for background */
    border-color: var(--primary-btn-bg);
}

.radio-option input[type="radio"]:checked::before {
    transform: scale(1); /* Show inner dot when checked */
}

/* Focus style for accessibility */
.radio-option input[type="radio"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-btn-bg); /* Focus ring */
}

/* Checkbox Group Styling */
.checkbox-group {
    display: flex;
    align-items: center;
    justify-content: center; /* Center the checkbox and label */
    gap: 10px; /* Increased gap */
    margin: 20px 0 15px 0; /* More top margin, less bottom */
    cursor: pointer; /* Make the whole area clickable */
}

/* Hide default checkbox */
.checkbox-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px; /* Custom size */
    height: 18px;
    border: 2px solid var(--text-muted-color); /* Use muted color for border */
    border-radius: 4px; /* Slightly rounded */
    cursor: pointer;
    position: relative;
    top: -1px; /* Fine-tune vertical alignment */
    transition: background-color 0.2s ease, border-color 0.2s ease;
    background-color: var(--bg-color); /* Match background */
}

/* Style for checked state */
.checkbox-group input[type="checkbox"]:checked {
    background-color: var(--primary-btn-bg); /* Use theme color */
    border-color: var(--primary-btn-bg);
}

/* Custom checkmark using pseudo-element */
.checkbox-group input[type="checkbox"]:checked::after {
    content: '\f00c'; /* Font Awesome check icon */
    font-family: 'Font Awesome 6 Free'; /* Ensure Font Awesome is loaded */
    font-weight: 900; /* Solid style */
    font-size: 12px;
    color: var(--primary-btn-text); /* Use button text color for check */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

/* Focus style for accessibility */
.checkbox-group input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-btn-bg); /* Focus ring */
}

.checkbox-group label {
    margin-bottom: 0;
    font-weight: 500; /* Slightly bolder label */
    font-size: 0.95em;
    color: var(--text-color); /* Ensure label color matches theme */
    cursor: pointer;
}

/* Helper Classes */
.small { font-size: 0.85em; color: var(--text-muted-color); }
.centered-text { text-align: center; display: block; margin-top: 5px; }
.highlight-info { color: var(--primary-btn-bg); font-weight: 500; }
.disclaimer { font-style: italic; color: var(--text-muted-color); margin-top: 10px; }
.error-message { color: #dc3545; font-size: 0.9em; margin-top: 10px; font-weight: 500; }

.info-text {
    margin-bottom: 5px; /* Add spacing between info lines */
    line-height: 1.4; /* Improve readability */
}

/* Footer */
.tool-footer {
    text-align: center;
    padding: 15px 0;
    margin-top: 30px;
    color: var(--text-muted-color);
    border-top: 1px solid var(--sidebar-link-hover-bg);
    font-size: 0.9em;
    width: 100%;
}

/* Responsive Adjustments */
@media (max-width: 900px) {
    .evalus-main-content {
        flex-direction: column; /* Stack columns on smaller screens */
    }
    .input-column,
    .results-column {
        width: 100%; /* Full width when stacked */
    }
    .evalus-header h1 {
        font-size: 1.5em;
    }
    .tab-button {
        padding: 10px 15px;
        font-size: 0.9em;
    }
}

@media (max-width: 600px) {
    .evalus-tool-container {
        padding: 15px;
    }
    .card {
        padding: 15px;
    }
    .form-grid {
        grid-template-columns: 1fr; /* Single column grid on very small screens */
    }
    .action-buttons-grouped {
        flex-direction: column;
    }
    .evalus-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    .view-switcher-tabs {
        justify-content: space-around; /* Better spacing on small screens */
    }
    .tab-button {
        flex-grow: 1; /* Allow tabs to fill space */
        text-align: center;
        justify-content: center;
    }
}

/* --- Custom Confirmation Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050; /* Ensure it's above other content */
    opacity: 0; /* Start hidden */
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

.modal-box {
    background-color: var(--card-bg);
    padding: 25px 30px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 450px; /* Max width of the modal */
    text-align: center;
    transform: scale(0.9); /* Start slightly smaller */
    transition: transform 0.3s ease;
}
.modal-overlay.visible .modal-box {
    transform: scale(1); /* Scale to full size when visible */
}

.modal-box h3 {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--text-color);
    margin-top: 0;
    margin-bottom: 15px;
}

.modal-box p {
    font-size: 1em;
    color: var(--text-muted-color);
    margin-bottom: 25px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: center; /* Center buttons */
    gap: 15px;
}

.modal-actions .action-button {
    min-width: 120px; /* Adjust button width */
}

/* Removed redundant styles previously added at the end */
/* Ensure danger button style applies */
.modal-actions .action-button.danger {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}
body.dark-mode .modal-actions .action-button.danger {
     background-color: #a12c34;
     border-color: #a12c34;
}
.modal-actions .action-button.danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
     body.dark-mode & {
         background-color: #8b232b;
         border-color: #8b232b;
     }
}
/* --- End Custom Confirmation Modal Styles --- */