/*
  File: simulator.css
  Description: Fully modular and centralized styling for the housing simulator.
               ALL visual aspects (layout, colors, spacing) are controlled from this file.
*/

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

/* 1. Global & Typography
-------------------------------------------------- */
.housing-simulator-body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: #f8f9fa;
    padding: 1rem; /* Default mobile padding */
}

@media (min-width: 768px) {
    .housing-simulator-body {
        padding: 4rem; /* Larger padding for desktop */
    }
}

/* This is the main H1 title outside the white box */
#simulator-title {
    font-size: 1.8rem; /* Mobile first title size */
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.5rem;
    color: #343a40;
}
@media (min-width: 768px) {
    #simulator-title {
        font-size: 2.5rem;
        margin-bottom: 2rem;
    }
}

/* This is the H2 title inside each step */
.step h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #343a40;
}
@media (min-width: 768px) {
    .step h2 {
        font-size: 1.75rem;
    }
}


/* 2. Main Layout & Structure (Overall Width and Padding Control)
-------------------------------------------------- */
#housing-simulator-root .container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    overflow: hidden;
}
#simulation-container {
    padding: 1.5rem; /* Mobile padding */
}
@media (min-width: 768px) {
    #simulation-container {
        padding: 3rem; /* Desktop padding */
    }
}


/* 3. Step Navigation
-------------------------------------------------- */
.step {
    transition: opacity 0.4s ease-in-out;
    width: 100%;
}
.step.hidden {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    /* Add visibility to prevent Flash of Unstyled Content (FOUC) */
    visibility: hidden;
}

/* 4. Option Grids (Layout Control)
-------------------------------------------------- */
/* This is where you control the layout of the option cards */
.simulator-options-grid {
    display: grid;
    gap: 1rem; /* Space between cards */
    grid-template-columns: 1fr; /* Default for mobile: 1 column */
    margin-bottom: 4rem; /* Added margin to create space between options and footer */
}

/* Larger screens */
@media (min-width: 768px) {
    .simulator-options-grid {
        gap: 1.5rem;
    }
    /* For grids with 3 items, display as 3 columns */
    #options-performanceGrade,
    #options-sprayFinish,
    #options-stairs {
        grid-template-columns: repeat(3, 1fr);
    }
    /* For grids with 4 items, display as 2x2 for better balance */
    #options-basicType,
    #options-plan,
    #options-exteriorWall,
    #options-flooring {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* 5. Section & Option Cards (Component Styling)
-------------------------------------------------- */
.section-header {
    background-color: #e7f5ff;
    color: #1c7ed6;
    padding: 0.5rem 1rem;
    display: inline-block;
    font-weight: 600;
    border-radius: 9999px;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.option-card {
    position: relative;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s ease-out;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    background-color: #fff;
    overflow: hidden;
    cursor: pointer;
}
.option-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.1);
    border-color: #adb5bd;
}
.option-card.selected {
    border-color: #228be6;
    box-shadow: 0 8px 16px -4px rgba(34, 139, 230, 0.2);
    background-color: #f1f9ff;
}

.option-card .card-content {
    padding: 1rem;
    text-align: left;
}
.option-card .card-title {
    display: block;
    font-weight: 600;
    color: #343a40;
    margin-bottom: 0.25rem;
}
.option-card .card-price {
    display: block;
    font-size: 0.875rem;
    color: #868e96;
}

.option-card .checkmark {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background-color: #228be6;
    border-radius: 50%;
    color: white;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
.option-card.selected .checkmark {
    display: flex;
}

/* 6. Image Styles
-------------------------------------------------- */
.simulator-option-image {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    display: block;
}
.simulator-result-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    flex-shrink: 0;
    border-radius: 8px;
}

/* 7. Navigation & Footer
-------------------------------------------------- */
#footer-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #ffffff;
    border-top: 1px solid #e9ecef;
}
.footer-left { text-align: left; flex: 1; }
.footer-center { text-align: center; flex: 2; }
.footer-right { text-align: right; flex: 1; }


#price-footer span:first-child {
    font-size: 0.8rem;
    color: #6c757d;
    display: block;
}
#price-footer #total-price {
    font-size: 1.75rem;
    font-weight: 700;
    color: #d9480f;
    line-height: 1.1;
}

@media (max-width: 767px) {
    #footer-nav {
        flex-direction: column;
        gap: 1rem;
    }
    .footer-left, .footer-center, .footer-right {
        text-align: center;
        width: 100%;
    }
    .footer-left { order: 3; }
    .footer-center { order: 1; }
    .footer-right { order: 2; }
}


/* Buttons */
#next-button, #contact-form button[type="submit"], #back-button {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    width: 100%;
    max-width: 280px; /* Max width for buttons */
}
#next-button, #contact-form button[type="submit"] {
    background-color: #228be6;
    color: white;
}
#next-button:hover, #contact-form button[type="submit"]:hover {
    background-color: #1971c2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 139, 230, 0.3);
}
#back-button {
    background-color: #e9ecef;
    color: #495057;
}
#back-button:hover {
    background-color: #dee2e6;
}
#edit-selections-button {
    color: #1c7ed6;
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
}
#edit-selections-button:hover {
    text-decoration: underline;
}

/* 8. Result Page Styles
-------------------------------------------------- */
.result-summary-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    background-color: #f8f9fa;
    padding: 1.5rem; /* Reduced padding for mobile */
    border-radius: 12px;
}
@media (min-width: 768px) {
    .result-summary-container {
        grid-template-columns: repeat(2, 1fr);
        padding: 2rem; /* Restore larger padding for desktop */
    }
}

.result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.result-item-details {
    display: flex;
    flex-direction: column;
}
.result-item-group {
    font-size: 0.875rem;
    color: #868e96;
}
.result-item-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: #343a40;
}
.result-item-price {
    font-weight: 600;
    color: #495057;
}

.result-total {
    grid-column: 1 / -1; /* Span full width */
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    flex-direction: column; /* Stack vertically on all screens */
    align-items: flex-end; /* Align to the right on all screens */
    gap: 0.25rem; /* Space between label and price */
}

.result-total span:first-child {
    font-size: 1.125rem;
    color: #495057;
    font-weight: 500;
    text-align: right; /* Ensure label is right-aligned too */
}

.result-total .total-price-amount {
    font-size: 2rem; /* Smaller font size for mobile */
    font-weight: 700;
    color: #d9480f;
    margin-left: 0; /* Remove left margin for mobile */
    white-space: nowrap; /* Prevents the currency symbol from wrapping */
}
@media (min-width: 768px) {
    .result-total .total-price-amount {
        font-size: 2.5rem; /* Restore larger font size for desktop */
    }
}


/* 9. Form Styles
-------------------------------------------------- */
.contact-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 768px) {
    .contact-form-grid {
        grid-template-columns: 1fr;
        /* Explicitly set column-gap to ensure spacing */
        column-gap: 1.5rem;
    }
    .form-full-width {
        grid-column: 1 / -1;
    }
}

#contact-form .form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    display: block;
}
#contact-form .form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
}
#contact-form .form-input:focus {
    outline: none;
    border-color: #228be6;
    box-shadow: 0 0 0 3px rgba(34, 139, 230, 0.2);
}
#contact-form textarea.form-input { min-height: 120px; }
#contact-form .checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
}
#contact-form input[type="checkbox"] {
    width: 1.25em;
    height: 1.25em;
    border-radius: 4px;
    border-color: #adb5bd;
    cursor: pointer;
}
#contact-form input[type="checkbox"]:checked {
    background-color: #228be6;
}

/* 10. Reception Method Radio Button Styles */
.reception-method-group {
    display: flex;
    border: 1px solid #ced4da;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
}
.reception-method-group label {
    flex: 1;
    margin-bottom: 0; /* Override default label margin */
    text-align: center;
    position: relative;
    display: block;
}
.reception-method-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.reception-method-group span {
    display: block;
    padding: 0.75rem 1rem;
    cursor: pointer;
    background-color: #fff;
    color: #495057;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-right: 1px solid #ced4da;
}
.reception-method-group label:last-child span {
    border-right: none;
}
.reception-method-group input[type="radio"]:checked + span {
    background-color: #228be6;
    color: #fff;
    font-weight: 600;
}