/* public/css/style.css - Light Theme - Iteration 4 (Complete) */

:root {
    /* Brand Colors (from your guide) */
    --brand-yellow: #ffd400;
    --brand-dark-blue-grey: #4f7187;
    --brand-teal: #47a7aa;
    --brand-orange: #f7941d;
    --brand-light-blue: #74cee2;

    /* Light Theme Palette */
    --site-background: #FFFFFF;
    --card-background: #FFFFFF;
    --text-primary: #212529;
    --text-secondary: #5a6268;
    --text-headings: var(--brand-dark-blue-grey);
    --border-color: #DEE2E6;

    --accent-primary: var(--brand-orange);
    --accent-primary-hover: #e0800d;
    --accent-primary-text: #FFFFFF;
    --focus-ring-color: rgba(247, 148, 29, 0.35);

    /* Pico CSS Variable Overrides */
    --pico-font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    --pico-font-size: 0.95rem;
    /* Base font size set to 1rem */
    --pico-line-height: 1.5;
    --pico-font-weight: 400;
    --pico-spacing: 0.7rem;

    --pico-color: var(--text-primary);
    --pico-muted-color: var(--text-secondary);
    --pico-primary: var(--accent-primary);
    --pico-primary-hover: var(--accent-primary-hover);
    --pico-primary-focus: var(--focus-ring-color);
    --pico-primary-inverse: var(--accent-primary-text);

    --pico-background-color: var(--site-background);
    --pico-card-background-color: var(--card-background);
    --pico-border-color: var(--border-color);
    --pico-form-element-background-color: #FFFFFF;
    --pico-form-element-border-color: #CED4DA;
    --pico-form-element-active-border-color: var(--accent-primary);
    --pico-form-element-focus-color: var(--accent-primary);
    --pico-table-border-color: var(--border-color);
    --pico-table-header-background: #F1F3F5;
    --pico-table-footer-background: #F8F9FA;
    --pico-code-background-color: #E9ECEF;
    --pico-code-color: var(--text-primary);

    --pico-h1-font-size: 2.25rem;
    --pico-h2-font-size: 1.75rem;
    --pico-h3-font-size: 1.4rem;
    --pico-h4-font-size: 1.15rem;
    --pico-h1-font-weight: 700;
    --pico-h2-font-weight: 600;
    --pico-h3-font-weight: 600;
    --pico-h4-font-weight: 600;

    --pico-border-radius: 0.3rem;
    --pico-block-spacing-vertical: var(--pico-spacing);
    --pico-block-spacing-horizontal: var(--pico-spacing);
    --pico-form-element-spacing-vertical: calc(var(--pico-spacing) * 0.7);
    --pico-form-element-spacing-horizontal: calc(var(--pico-spacing) * 0.9);

    --pico-container-max-width: 1120px;
}

/* --- Global Resets & Base Styles --- */
html {
    font-family: var(--pico-font-family);
    font-size: var(--pico-font-size);
    line-height: var(--pico-line-height);
    background-color: var(--pico-background-color);
    color: var(--pico-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-sizing: border-box;
}

*,
*:before,
*:after {
    box-sizing: inherit;
}

body {
    font-weight: var(--pico-font-weight);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main.container {
    flex-grow: 1;
    width: 100%;
    max-width: var(--pico-container-max-width);
    margin-left: auto;
    margin-right: auto;
    padding: calc(var(--pico-spacing) * 1.5) var(--pico-block-spacing-horizontal);
}


/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--pico-font-family);
    color: var(--text-headings);
    margin-top: calc(var(--pico-spacing) * 1.5);
    margin-bottom: calc(var(--pico-spacing) * 0.75);
    font-weight: 600;
}

h1 {
    font-size: var(--pico-h1-font-size);
    font-weight: var(--pico-h1-font-weight);
}

h2 {
    font-size: var(--pico-h2-font-size);
    font-weight: var(--pico-h2-font-weight);
}

h3 {
    font-size: var(--pico-h3-font-size);
    font-weight: var(--pico-h3-font-weight);
}

h4 {
    font-size: var(--pico-h4-font-size);
    font-weight: var(--pico-h4-font-weight);
}

article>header:first-child h1,
article>header:first-child h2 {
    font-family: "Chakra Petch", "Plus Jakarta Sans", sans-serif;
    font-weight: 700;
    line-height: 1.3;
}

p {
    margin-bottom: var(--pico-spacing);
    font-size: 1rem;
    /* Ensure paragraphs are also 1rem */
    line-height: var(--pico-line-height);
    /* Ensure consistent line height */
}

small {
    font-size: 0.875em;
    /* Relative to parent, so if parent is 1rem, this is 14px */
    color: var(--text-secondary);
}

/* --- Links --- */
a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}

a:hover,
a:focus {
    color: var(--accent-primary-hover);
    text-decoration: underline;
}

/* --- Horizontal Rule --- */
hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin-top: calc(var(--pico-spacing) * 2);
    margin-bottom: calc(var(--pico-spacing) * 2);
}

/* --- Article/Card Styling --- */
article,
.card {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--pico-border-radius);
    padding: calc(var(--pico-spacing) * 2);
    margin-bottom: calc(var(--pico-spacing) * 1.5);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
}

article header:first-child,
.card header:first-child {
    margin: calc(-1 * var(--pico-spacing) * 2) calc(-1 * var(--pico-spacing) * 2) var(--pico-spacing);
    padding: var(--pico-spacing) calc(var(--pico-spacing) * 2);
    border-bottom: 1px solid var(--border-color);
    background-color: #F8F9FA;
    border-top-left-radius: var(--pico-border-radius);
    border-top-right-radius: var(--pico-border-radius);
}

article header:first-child h1,
article header:first-child h2,
article header:first-child h3 {
    margin-top: 0;
    margin-bottom: 0;
}


/* --- Button Styling --- */
button,
input[type="submit"],
input[type="reset"],
input[type="button"],
a.button,
a[role="button"] {
    background-color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary-text) !important;
    font-family: var(--pico-font-family);
    /* Ensure buttons use the main font */
    font-size: 0.9375rem;
    /* Slightly smaller than base for buttons, or keep at 1rem */
    font-weight: 500;
    padding: calc(var(--pico-form-element-spacing-vertical) * 1.2) calc(var(--pico-form-element-spacing-horizontal) * 1.8);
    border-radius: var(--pico-border-radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07);
    text-transform: none;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    line-height: normal;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

button:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
input[type="button"]:hover,
a.button:hover,
a[role="button"]:hover {
    background-color: var(--accent-primary-hover);
    border-color: var(--accent-primary-hover);
    color: var(--accent-primary-text) !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

button:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
input[type="button"]:focus,
a.button:focus,
a[role="button"]:focus {
    outline: none;
    border-color: var(--accent-primary-hover);
    box-shadow: 0 0 0 0.2rem var(--focus-ring-color);
    text-decoration: none;
}

button.secondary,
a.button.secondary,
a[role="button"].secondary {
    background-color: #E9ECEF;
    border-color: #CED4DA;
    color: var(--text-headings) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

button.secondary:hover,
a.button.secondary:hover,
a[role="button"].secondary:hover {
    background-color: #DEE2E6;
    border-color: #BDBDBD;
    color: var(--text-headings) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

button.secondary:focus,
a.button.secondary:focus,
a[role="button"].secondary:focus {
    outline: none;
    border-color: var(--text-headings);
    box-shadow: 0 0 0 0.2rem rgba(79, 113, 135, 0.25);
}

button.contrast,
a.button.contrast,
a[role="button"].contrast {
    background-color: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary) !important;
    box-shadow: none;
}

button.contrast:hover,
a.button.contrast:hover,
a[role="button"].contrast:hover {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--accent-primary-text) !important;
}

button.contrast:focus,
a.button.contrast:focus,
a[role="button"].contrast:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 0.2rem var(--focus-ring-color);
}


/* --- Input and Form Element Styling --- */
label {
    display: block;
    margin-bottom: calc(var(--pico-spacing) * 0.5);
    font-weight: 500;
    color: var(--text-headings);
    font-size: 0.9375em;
}

input:not([type=checkbox]):not([type=radio]):not([type=range]),
select,
textarea {
    background-color: var(--pico-form-element-background-color);
    border: 1px solid var(--pico-form-element-border-color);
    color: var(--text-primary);
    border-radius: var(--pico-border-radius);
    padding: var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
    width: 100%;
    margin-bottom: calc(var(--pico-spacing) * 1.25);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    font-size: 1rem;
    /* Input text at 1rem */
    line-height: var(--pico-line-height);
    /* Ensure consistent line height */
}

input:not([type=checkbox]):not([type=radio]):not([type=range]):focus,
select:focus,
textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 0.2rem var(--focus-ring-color);
    outline: none;
}

::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

select {
    appearance: none;
    background-image: var(--pico-icon-chevron-down);
    background-repeat: no-repeat;
    background-position: right var(--pico-form-element-spacing-horizontal) center;
    padding-right: calc(var(--pico-form-element-spacing-horizontal) * 2.5);
}

fieldset {
    border: 1px solid var(--border-color);
    padding: calc(var(--pico-spacing) * 1.5) calc(var(--pico-spacing) * 2);
    margin-bottom: calc(var(--pico-spacing) * 2);
    border-radius: var(--pico-border-radius);
}

legend {
    font-size: 1.2em;
    font-weight: 600;
    padding: 0 calc(var(--pico-spacing) * 0.75);
    color: var(--text-headings);
    margin-bottom: var(--pico-spacing);
}


/* --- Table Styling --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--pico-spacing);
    margin-bottom: calc(var(--pico-spacing) * 2);
    font-size: 1rem;
    /* Table text at 1rem */
    border: 1px solid var(--border-color);
}

table th,
table td {
    border: 1px solid var(--border-color);
    padding: var(--pico-spacing);
    text-align: left;
    vertical-align: middle;
}

table thead th {
    background-color: var(--pico-table-header-background);
    color: var(--text-headings);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    white-space: normal;
    vertical-align: middle;
}

table tbody tr td {
    background-color: transparent;
    color: var(--text-primary);
}

table tfoot td {
    background-color: var(--pico-table-footer-background);
    font-weight: bold;
    color: var(--text-headings);
    border-top: 2px solid var(--border-color);
}

table td[style*="text-align: right"],
table th[style*="text-align: right"] {
    text-align: right;
}

/* --- Navigation Bar Styling --- */
nav.container-fluid {
    background-color: var(--site-background);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    /* Removed direct padding, will be handled by inner .container */
}

nav.container-fluid>.container {
    /* The single .container inside nav from layouts/main.ejs */
    max-width: var(--pico-container-max-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--pico-block-spacing-horizontal);
    /* Standard page padding */
    padding-right: var(--pico-block-spacing-horizontal);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

nav ul {
    margin: 0;
    display: flex;
    align-items: center;
    padding-left: 0;
    height: 100%;
}

nav ul li {
    list-style: none;
    padding-left: 0;
    margin-left: calc(var(--pico-spacing) * 1.85);
    display: flex;
    align-items: center;
}

nav ul li:first-child {
    /* No left margin for the first item in a nav UL */
    margin-left: 0;
}

/* Target the brand name specifically if it's in the first UL */
nav .container>ul:first-of-type li:first-child {
    margin-right: auto;
    /* Push the subsequent UL (nav links) to the right */
}

nav ul li a,
nav ul li strong {
    color: var(--text-headings);
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
    padding: calc(var(--pico-spacing) * 0.4) 0;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
    white-space: nowrap;
}

nav ul li a:hover,
nav ul li a:focus,
nav ul li a.active {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom-color: var(--accent-primary);
}

nav ul li a.brand-logo-link {
    display: flex;
    /* Align logo and text horizontally */
    align-items: center;
    /* Vertically align logo and text */
    text-decoration: none;
    /* Remove underline from the link */
    padding: 0;
    /* Remove default padding from nav links if it interferes */
    border-bottom: none;
    /* Remove the border-bottom effect from general nav links */
}

nav ul li a.brand-logo-link:hover,
nav ul li a.brand-logo-link:focus {
    border-bottom: none;
    color: var(--text-headings);
}

.navbar-logo {
    height: 30px;
    /* ADJUST HEIGHT AS NEEDED - this will scale the SVG/image */
    width: auto;
    /* Maintain aspect ratio */
    margin-right: 0.5rem;
    /* Space between logo and "Forecast" text */
    display: block;
}

.brand-forecast-text {
    font-family: var(--pico-font-family);
    /* Plus Jakarta Sans */
    font-size: 1.3em;
    /* Make "Forecast" prominent, adjust as needed */
    font-weight: 600;
    /* Semibold */
    color: var(--accent-primary);
    line-height: 1;
    /* Ensure it aligns well with the logo */
    margin-left: 0.25rem;
    /* Small space if margin-right on logo isn't enough */
}

nav .container>ul:first-of-type li:first-child {
    margin-left: 0;
    margin-right: auto;
    display: flex;
    align-items: center;
    height: 100%;
}

/* Remove any specific margin-right on the strong tag if it was previously used for spacing */
nav .container>ul:first-of-type li:first-child strong {
    margin-right: 0;
}


/* --- Footer Styling --- */
body>footer.container {
    padding: var(--pico-spacing) var(--pico-block-spacing-horizontal);
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.9rem;
    /* Slightly smaller footer text, but still readable */
    color: var(--text-secondary);
}

.estimate-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--pico-spacing);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--pico-spacing);
}

.estimate-header h1 {
    margin-bottom: 0;
    line-height: 1.3;
    color: var(--text-headings);
    /* Chakra Petch applied by article > header:first-child h1 */
}

.estimate-header h2 {
    /* Project Name */
    text-align: right;
    color: var(--text-primary);
    font-family: var(--pico-font-family);
    font-weight: 600;
    font-size: var(--pico-h2-font-size);
    margin-bottom: 0;
    line-height: 1.3;
}

.project-details-bar {
    font-size: 1rem;
    /* Set to 1rem */
    color: var(--text-primary);
    padding: var(--pico-spacing);
    margin-top: calc(var(--pico-spacing) * 1.5);
    margin-bottom: calc(var(--pico-spacing) * 2);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-primary);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: var(--pico-spacing);
    background-color: #FDFDFD;
    border-radius: var(--pico-border-radius);
}

.project-details-bar>div {
    padding: calc(var(--pico-spacing) * 0.25) 0;
}

.project-details-bar>div strong {
    color: var(--text-headings);
    margin-right: calc(var(--pico-spacing) * 0.5);
}


/* Terms and Conditions specific styling */
.terms-and-conditions-main {
    font-size: 1rem;
    /* Set to 1rem */
    line-height: 1.65;
    margin-top: calc(var(--pico-spacing) * 2);
    color: var(--text-primary);
}

.terms-and-conditions-main .terms-block {
    margin-bottom: 1.75em;
}

.terms-and-conditions-main h3 {
    font-family: var(--pico-font-family);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-headings);
    margin-top: var(--pico-spacing);
    margin-bottom: 0.85em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--pico-spacing) * 0.4);
}

.terms-and-conditions-main ul,
.terms-and-conditions-main ol {
    padding-left: 1.75em;
    margin-top: 0.5em;
    margin-bottom: 1em;
}

.terms-and-conditions-main li {
    margin-bottom: 0.5em;
}

.terms-and-conditions-main p {
    margin-bottom: 1em;
}

/* --- Error Message Styling --- */
.error-message,
p[role="alert"] {
    background-color: #FFF3CD;
    border: 1px solid #FFEEBA;
    color: #856404;
    padding: var(--pico-spacing);
    margin-bottom: var(--pico-spacing);
    border-radius: var(--pico-border-radius);
}

select.status-dropdown {
    border-width: 1px;
    /* Ensure border is visible */
    padding: calc(var(--pico-form-element-spacing-vertical) * 0.8) calc(var(--pico-form-element-spacing-horizontal) * 2.5)
        /* Adjust padding for select */
        calc(var(--pico-form-element-spacing-vertical) * 0.8) var(--pico-form-element-spacing-horizontal);
    font-weight: 500;
    border-radius: var(--pico-border-radius);
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

select.status-won {
    background-color: #D4EDDA;
    /* Light green */
    border-color: #C3E6CB;
    color: #155724;
    /* Dark green text */
}

select.status-lost {
    background-color: #F8D7DA;
    /* Light red */
    border-color: #F5C6CB;
    color: #721C24;
    /* Dark red text */
}

select.status-submitted {
    background-color: #E2E3E5;
    /* Light grey */
    border-color: #D6D8DB;
    color: #383D41;
    /* Dark grey text */
}

/* Ensure focus styles still work well with colored backgrounds */
select.status-dropdown:focus {
    border-color: var(--accent-primary);
    /* Your main accent color for focus border */
    box-shadow: 0 0 0 0.2rem var(--focus-ring-color);
    /* Your main focus ring */
}

/* Add red star for required fields - Star BEFORE label text */
label:has(+ input[required])::before,
label:has(+ select[required])::before,
label:has(+ textarea[required])::before,
label:has(input[required])::before,
/* If input/select is nested inside label */
label:has(select[required])::before,
label:has(textarea[required])::before {
    content: "*";
    color: var(--brand-orange);
    /* Or your preferred red */
    font-weight: normal;
    font-size: 1.1em;
    margin-right: 4px;
    /* Space between star and label text */
}

input.input-short-number {
    width: auto;
    min-width: 100px;
    max-width: 150px;
    display: block;
}