/* General Reset & Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa; /* Lighter grey background */
    color: #333; /* Darker text for readability */
    line-height: 1.6;
}

.container {
    width: 90%;
    max-width: 1200px; /* Max width for larger screens */
    margin: 0 auto; /* Centering */
    padding: 0 15px; /* Padding for smaller screens */
}

/* Header Styles */
header {
    background: #ffffff; /* White background for header */
    color: #333;
    padding: 20px 0;
    border-bottom: 1px solid #e7e7e7; /* Subtle border */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); /* Subtle shadow */
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-placeholder a {
    font-size: 1.8em;
    font-weight: bold;
    color: #007bff; /* Primary color for logo */
    text-decoration: none;
}

header nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
}

header nav ul li {
    margin-left: 20px;
}

header nav ul li a {
    text-decoration: none;
    color: #555; /* Slightly lighter nav text */
    font-weight: 500;
    transition: color 0.3s ease;
}

header nav ul li a:hover,
header nav ul li a.active { /* Assuming an 'active' class for current page */
    color: #007bff; /* Primary color on hover/active */
}

/* Main Content Styles */
main {
    padding: 30px 0; /* More padding for main content */
}

h1, h2, h3, h4, h5, h6 {
    color: #333;
    margin-top: 0;
    margin-bottom: 0.75em;
    font-weight: 600; /* Slightly bolder headings */
}

h1 { font-size: 2.2em; }
h2 { font-size: 1.8em; }
h3 { font-size: 1.5em; }

p {
    margin-bottom: 1em;
}

a {
    color: #007bff; /* Consistent link color */
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Form Styles */
/* 
form {
    background: #ffffff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
*/

form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
    width: calc(100% - 22px); /* Full width minus padding */
    padding: 10px;
    border: 1px solid #ced4da; /* Softer border color */
    border-radius: 4px;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    border-color: #007bff; /* Highlight focus */
    outline: none;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

button,
input[type="submit"] { /* Style submit inputs like buttons */
    background-color: #007bff; /* Primary button color */
    color: white;
    border: none;
    padding: 12px 25px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 1em;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

button:hover,
input[type="submit"]:hover {
    background-color: #0056b3; /* Darker shade on hover */
}

/* Footer Styles */
footer {
    background: #343a40; /* Dark footer */
    color: #f8f9fa; /* Light text on dark background */
    text-align: center;
    padding: 30px 0;
    margin-top: 40px; /* Space above footer */
}

footer p {
    margin-bottom: 0.5em;
}

footer a {
    color: #00aeff; /* Lighter blue for links in footer */
}

footer a:hover {
    color: #ffffff;
}

/* Utility Classes */
.error {
    color: #dc3545; /* Bootstrap danger color */
    background-color: #f8d7da; /* Light red background */
    border: 1px solid #f5c6cb;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.success {
    color: #28a745; /* Bootstrap success color */
    background-color: #d4edda; /* Light green background */
    border: 1px solid #c3e6cb;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* Alert Styles (similar to Bootstrap for compatibility) */
.alert {
    position: relative;
    padding: .75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: .25rem;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeeba;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}


/* Form Group for spacing */
.form-group {
    margin-bottom: 1rem; /* Standard spacing for form groups */
}

/* Additional Button Styles */
.btn { /* Base class if not already fully defined by 'button' */
    display: inline-block;
    font-weight: 400;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: .375rem .75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: .25rem;
    transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.btn-primary {
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
}
.btn-primary:hover {
    color: #fff;
    background-color: #0056b3; /* Standard darker hover for primary */
    border-color: #00529c; /* Standard darker hover for primary border */
}

.btn-secondary {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}
.btn-secondary:hover {
    color: #fff;
    background-color: #5a6268;
    border-color: #545b62;
}

.btn-info {
    color: #fff;
    background-color: #17a2b8;
    border-color: #17a2b8;
}
.btn-info:hover {
    color: #fff;
    background-color: #138496;
    border-color: #117a8b;
}

.btn-warning {
    color: #212529;
    background-color: #ffc107;
    border-color: #ffc107;
}
.btn-warning:hover {
    color: #212529;
    background-color: #e0a800;
    border-color: #d39e00;
}

.btn-danger {
    color: #fff;
    background-color: #dc3545;
    border-color: #dc3545;
}
.btn-danger:hover {
    color: #fff;
    background-color: #c82333;
    border-color: #bd2130;
}

.btn-sm {
    padding: .25rem .5rem;
    font-size: .875rem;
    line-height: 1.5;
    border-radius: .2rem;
}

/* Margin Utility */
.mb-4 {
    margin-bottom: 1.5rem !important; /* Corresponds to Bootstrap's mb-4 */
}

/* Pagination Styles */
.pagination {
    display: flex;
    padding-left: 0;
    list-style: none;
    border-radius: .25rem;
    margin-top: 20px;
    margin-bottom: 20px;
    justify-content: center; /* Center pagination */
}

.pagination a, .pagination strong, .pagination span {
    position: relative;
    display: block;
    padding: .5rem .75rem;
    margin-left: -1px;
    line-height: 1.25;
    color: #007bff;
    background-color: #fff;
    border: 1px solid #dee2e6;
    text-decoration: none;
}

.pagination a:hover {
    z-index: 2;
    color: #0056b3;
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.pagination strong { /* Current page */
    z-index: 1;
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
}

.pagination span { /* Ellipsis */
    color: #6c757d; /* Muted color for ellipsis */
     background-color: #fff;
    border: 1px solid #dee2e6;
}

.pagination a:first-child {
    margin-left: 0;
    border-top-left-radius: .25rem;
    border-bottom-left-radius: .25rem;
}

.pagination a:last-child {
    border-top-right-radius: .25rem;
    border-bottom-right-radius: .25rem;
}

/* Specific Styles */
#add_ingredient_row {
    background-color: #007bff; /* Primary blue color */
    color: white; /* White text */
    border: none; /* Remove border */
    padding: 10px 15px; /* Add padding */
    border-radius: 4px; /* Rounded corners */
    cursor: pointer; /* Pointer cursor on hover */
    transition: background-color 0.3s ease; /* Smooth hover effect */
}

#add_ingredient_row:hover {
    background-color: #0056b3; /* Darker blue on hover */
}

/* Styles from create_recipe.php */
.ingredient-row-flex {
    display: flex;
    align-items: center;
    gap: 10px;
}

.new-ingredient-item-row-dynamic {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #ddd;
}

.remove-new-ingredient-button {
    margin-top: 5px;
}

/* Styles from edit_recipe.php */
.ingredient-row-styled {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 10px;
}

.new-ingredient-item-row-edit {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #ddd;
}

.remove-new-ingredient-button-edit {
    margin-top: 5px;
}

.button-danger-edit {
    background: none;
    border: none;
    color: red;
    font-size: 1.2em;
    cursor: pointer;
    padding: 0;
}

/* Styles from view_recipe.php */
.view-recipe-container {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.view-recipe-serving-size-form {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0;
    flex-shrink: 0;
}

.view-recipe-serving-size-label {
    margin-bottom: 0;
    font-size: 0.9em;
    color: #555;
}

.view-recipe-serving-size-input {
    width: 70px;
    padding: 3px 8px; /* Reduced vertical padding from 6px to 3px */
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
}

.view-recipe-serving-size-button {
    padding: 3px 12px; /* Reduced vertical padding from 6px to 3px */
    background-color: #5cb85c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.view-recipe-display-options-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-grow: 1;
    flex-wrap: wrap;
}

.view-recipe-checkbox-label {
    margin-bottom: 0;
    font-size: 0.9em;
    color: #555;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.view-recipe-checkbox-input {
    margin-right: 3px;
}

.view-recipe-rdi-section {
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.view-recipe-rdi-title {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #333;
}

.view-recipe-rdi-toggle-button {
    padding: 8px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.view-recipe-rdi-form-container {
    /* display:none; Initially hidden by JS */
    padding: 15px;
    border: 1px solid #ccc;
    background-color: #fff;
    border-radius: 4px;
}

.view-recipe-rdi-form-description {
    font-size: 0.9em;
    color: #555;
    margin-top: 0;
}

.view-recipe-rdi-field-container {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-recipe-rdi-field-label {
    font-size: 0.9em;
    color: #555;
    width: 140px;
    flex-shrink: 0;
}

.view-recipe-rdi-field-input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
}

.view-recipe-rdi-field-unit {
    font-size: 0.85em;
    color: #777;
}

.view-recipe-rdi-save-button {
    padding: 8px 15px;
    background-color: #5cb85c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    margin-top: 10px;
}
.view-recipe-rdi-form {
    display: inline-block;
    margin-top: 10px;
}
.view-recipe-rdi-reset-button {
    padding: 8px 15px;
    background-color: #f0ad4e;
    color: white;
    border-color: #eea236; /* Assuming you want to keep this specific border color */
    border-style: solid; /* Ensure border is visible */
    border-width: 1px; /* Ensure border is visible */
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.nutrition-options-container {

    padding: 15px;
    border: 1px solid #ddd;
    background-color: #f7f7f7;
    border-radius: 6px;
}

.nutrition-options-title {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1em;
    color: #333;
}
.view-recipe-flex-wrap-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}
.salt-calculated-italic {
    font-style: italic;
}

/* Styles from manage_ingredients.php */
/* .manage-ingredients-vitamin-mineral-fields {display: none;} */ /* Remove or comment out if not used */

/* NEW STYLES FOR MANAGE_INGREDIENTS.PHP */

/* General container for the page content if needed, assuming .container is already well-styled */

/* Page Header (Title and Create Button) */
.page-header-manage-ingredients {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px; /* Or your preferred margin */
}

.page-header-manage-ingredients h2 {
    margin: 0;
    margin-right: auto; /* This will push the button to the right */
    font-size: 1.75rem; /* Slightly smaller than h1 for page titles */
    color: #343a40; /* Darker heading color */
}

.page-header-manage-ingredients .btn-primary {
    background-color: #007bff;
    border-color: #007bff;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}
.page-header-manage-ingredients .btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}


/* Search Form Styling */
.search-form-manage-ingredients .input-group {
    margin-bottom: 1.5rem; /* Space below search bar */
}

.search-form-manage-ingredients .form-control {
    border-radius: 0.25rem 0 0 0.25rem; /* Rounded left corners */
    border-color: #ced4da;
    padding: 0.5rem 0.75rem;
}
.search-form-manage-ingredients .form-control:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.search-form-manage-ingredients .btn-outline-secondary {
    border-radius: 0 0.25rem 0.25rem 0; /* Rounded right corners */
    border-color: #ced4da;
    color: #6c757d;
    padding: 0.5rem 0.75rem;
}
.search-form-manage-ingredients .btn-outline-secondary:hover {
    background-color: #6c757d;
    color: #fff;
}

/* Ingredient Section Styling */
.ingredient-section {
    margin-bottom: 2rem; /* Space between sections (My Private, Public) */
    background-color: #fff; /* Card-like background for sections */
    padding: 1.5rem;
    border-radius: 0.3rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ingredient-section h3 {
    font-size: 1.3rem;
    color: #495057;
    margin-top: 0; /* Remove default margin */
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

/* Table Styling */
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: #212529;
    border-collapse: collapse; /* Ensure borders are clean */
}

.table th,
.table td {
    padding: 0.75rem; /* Standard padding */
    vertical-align: middle; /* Align content vertically */
    border-top: 1px solid #dee2e6; /* Horizontal lines */
    font-size: 0.9rem; /* Slightly smaller font for table content */
}

.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid #dee2e6; /* Heavier border for header bottom */
    background-color: #f8f9fa; /* Light background for header */
    color: #495057;
    font-weight: 600; /* Bolder header text */
    text-align: left;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02); /* Very subtle striping */
}
.table-striped tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.04); /* Hover effect for rows */
}

.table-sm th,
.table-sm td {
    padding: 0.5rem; /* Reduced padding for .table-sm */
}

.table td a {
    color: #007bff;
    text-decoration: none;
}
.table td a:hover {
    text-decoration: underline;
    color: #0056b3;
}


/* Action Buttons in Table */
.table .actions-cell {
    white-space: nowrap; /* Prevent buttons from wrapping */
    text-align: right; /* Align buttons to the right */
}

.table .actions-cell .btn {
    margin-left: 0.25rem; /* Space between buttons */
    margin-bottom: 0; /* Remove bottom margin if added by .mb-1 previously */
    padding: 0.25rem 0.5rem; /* Smaller padding for action buttons */
    font-size: 0.8rem;
}
.table .actions-cell .btn:first-child {
    margin-left: 0;
}


.table .btn-warning { color: #212529; background-color: #ffc107; border-color: #ffc107;}
.table .btn-warning:hover { background-color: #e0a800; border-color: #d39e00;}

.table .btn-info { color: #fff; background-color: #17a2b8; border-color: #17a2b8;}
.table .btn-info:hover { background-color: #138496; border-color: #117a8b;}

.table .btn-danger { color: #fff; background-color: #dc3545; border-color: #dc3545;}
.table .btn-danger:hover { background-color: #c82333; border-color: #bd2130;}

.table .btn-primary { /* For Duplicate as Private button */
    color: #fff; 
    background-color: #007bff; 
    border-color: #007bff;
}
.table .btn-primary:hover {
    color: #fff;
    background-color: #0056b3; /* Standard darker hover for primary */
    border-color: #00529c; /* Standard darker hover for primary border */
}

/* Action buttons for public ingredients can be added here if needed */

/* No ingredients message */
.ingredient-section p {
    color: #6c757d;
    font-style: italic;
    margin-top: 1rem;
}

/* Pagination - General Styling (if not already covered by global .pagination) */
.pagination {
    display: flex;
    justify-content: center; /* Center pagination */
    padding-left: 0;
    list-style: none;
    border-radius: 0.25rem;
    margin-top: 1.5rem; /* Space above pagination */
}

.pagination a, .pagination strong, .pagination span {
    padding: 0.5rem 0.75rem;
    margin-left: -1px; /* Collapse borders */
    line-height: 1.25;
    color: #007bff;
    background-color: #fff;
    border: 1px solid #dee2e6;
    text-decoration: none;
}

.pagination a:hover {
    z-index: 2;
    color: #0056b3;
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.pagination strong { /* Current page */
    z-index: 1;
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
}

.pagination span { /* Ellipsis */
    color: #6c757d;
    background-color: #fff;
    border: 1px solid #dee2e6;
}

.pagination a:first-child {
    margin-left: 0;
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
}

.pagination a:last-child {
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}


/* Styles for sortable tables */
.sortable-header {
    cursor: pointer;
    position: relative; /* For positioning the indicator */
}

.sortable-header .header-text {
    margin-right: 20px; /* Increased space for the indicator */
}

.sortable-header .sort-indicator {
    font-size: 0.9em;
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-block; /* Ensure it takes space for content */
    width: 1em; /* Give it some width */
    text-align: center; /* Center the arrow */
    line-height: 1; /* Ensure arrow aligns well */
}

.sortable-header.sort-asc .sort-indicator::after {
    content: '\25B2'; /* Upwards black triangle ▲ */
    color: #007bff; 
}

.sortable-header.sort-desc .sort-indicator::after {
    content: '\25BC'; /* Downwards black triangle ▼ */
    color: #007bff; 
}

/* Optional: Style for sortable headers that are not currently sorted (e.g., a faint default indicator) */
.sortable-header:not(.sort-asc):not(.sort-desc) .sort-indicator::after {
    content: ''; /* Or use '↕' (\2195) for up-down arrow if desired, with a muted color */
    /* color: #ccc; */
}


/* General Table styling improvements (Optional, can be adjusted) */
.ingredients-table {
    margin-bottom: 2rem; /* Add some space below tables */
}

.ingredients-table th, .ingredients-table td {
    vertical-align: middle; /* Align cell content vertically */
}

.actions-cell .btn {
    margin-right: 5px; /* Space out action buttons */
    margin-bottom: 5px; /* Ensure buttons wrap nicely on small screens */
}

/* Responsive adjustments for tables */
@media (max-width: 768px) {
    .page-header-manage-ingredients {
        flex-direction: column;
        align-items: flex-start;
    }
    .page-header-manage-ingredients h2 {
        margin-bottom: 0.5rem;
    }
    .page-header-manage-ingredients .btn-primary {
        align-self: flex-start; /* Or flex-end if preferred */
    }

    .table thead {
        display: none; /* Hide table header on small screens */
    }
    .table tbody, .table tr, .table td {
        display: block; /* Make table elements block level */
        width: 100%;
    }
    .table tr {
        margin-bottom: 1rem; /* Space between "cards" */
        border: 1px solid #dee2e6;
        border-radius: 0.25rem;
    }
    .table td {
        text-align: right; /* Align cell content to the right */
        padding-left: 50%; /* Create space for the data-label */
        position: relative;
        border: none; /* Remove default cell borders */
        border-bottom: 1px solid #eee; /* Separator for stacked items */
    }
    .table td:last-child {
        border-bottom: none;
    }
    .table td::before {
        content: attr(data-label); /* Use data-label for pseudo-header */
        position: absolute;
        left: 0.75rem; /* Align with cell padding */
        width: calc(50% - 1.5rem); /* Adjust width based on padding */
        padding-right: 0.5rem;
        font-weight: bold;
        text-align: left;
        white-space: nowrap;
    }
    .table .actions-cell {
        text-align: right; /* Keep actions aligned right */
        padding-left: 0.75rem; /* Reset padding for actions cell */
    }
     .table .actions-cell::before {
        display: none; /* No pseudo-header for actions */
    }
    .table .actions-cell .btn {
        display: block; /* Stack action buttons */
        width: 100%;
        margin-left: 0;
        margin-bottom: 0.5rem;
    }
    .table .actions-cell .btn:last-child {
        margin-bottom: 0;
    }
    .table .actions-cell form .btn { /* Ensure form button also stacks */
        display: block;
        width: 100%;
        margin-left: 0;
        margin-bottom: 0.5rem;
    }
}