/* --- GLOBAL STYLES & RESETS --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #e63946; /* A strong red from a popular palette, similar to the mockup's accent */
    --primary-color-light: #f1faee;
    --secondary-color: #457b9d;
    --background-color: #f7f8fc;
    --text-color: #212529;
    --label-color: #495057;
    --border-color: #ced4da;
    --border-color-focus: #e63946;
    --card-shadow: 0 8px 25px rgba(0, 0, 0, 0.07);
    --font-family: 'Vazirmatn', sans-serif;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.7;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- MAIN LAYOUT --- */
.main-container {
    max-width: 900px;
    margin: 20px auto;
    background-color: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
    padding: 30px 40px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.6s ease-out forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculator-header {
    text-align: center;
    margin-bottom: 40px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 25px;
}

.calculator-header h1 {
    font-size: 2.2em;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 10px;
}

.calculator-header p {
    font-size: 1.1em;
    color: var(--label-color);
    max-width: 500px;
    margin: 0 auto;
}

/* --- CARD SECTIONS --- */
.card-section {
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius-lg);
    padding: 25px 30px;
    margin-bottom: 25px;
}

.card-section h3 {
    font-size: 1.4em;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.card-section h3 .bi {
    color: var(--primary-color);
}

/* --- FORM STYLES --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    color: var(--label-color);
    margin-bottom: 8px;
    font-size: 0.95em;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 1em;
    font-family: inherit;
    background-color: #fff;
    transition: all 0.2s ease-in-out;
}

.form-group select {
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 0.75rem center;
    background-size: 16px 12px;
    padding-left: 35px; /* space for arrow */
}

.form-group input::placeholder {
    color: #adb5bd;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
}

/* --- BUTTONS --- */
.action-buttons {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.calculate-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 50px;
    font-size: 1.1em;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.calculate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(230, 57, 70, 0.2);
}

.calculate-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 5px 10px rgba(230, 57, 70, 0.2);
}

/* --- RESULT AREA --- */
#result {
    margin-top: 40px;
    padding: 0;
    background: none;
    border: none;
    display: none;
}

.result-card {
    background-color: #fff;
    border: 1px solid var(--primary-color-light);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    animation: fadeIn 0.5s ease-out;
}

.result-header {
    background-color: var(--primary-color);
    color: white;
    padding: 20px 25px;
}

.result-header h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0;
}
.result-body {
    padding: 25px;
}

.result-summary p {
    background-color: var(--primary-color-light);
    color: #1d3557;
    padding: 15px;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    line-height: 1.8;
    margin-bottom: 25px;
    text-align: center;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.result-grid-item {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: var(--border-radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
        display: none !important;
}

.grid-label {
    font-weight: 500;
    color: var(--label-color);
}

.grid-value {
    font-weight: 700;
    color: var(--secondary-color);
    text-align: left;
}

/* Loading Spinner */
.loading {
    text-align: center;
    padding: 50px;
}
.result-summary p {
background: #e6f9e0;
    padding: 16px 24px;
    border-radius: 12px;
    border: 1px solid #c3e8b7;
}
    
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Recommended Products */
#recommendedProductsContainer h3 {
    font-size: 1.2em;
    color: var(--secondary-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}
.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #f0f0f0;
}
.result-item:last-child {
    border-bottom: none;
}
.result-item img {
    border-radius: 8px;
    border: 1px solid #eee;
}
@media (min-width: 768px) {
.result-item img {
    border-radius: 8px;
    border: 1px solid #eee;
    width: 300px !important;
    object-fit: contain !important;
}
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 768px) {
    .main-container {
        padding: 20px;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .calculator-header h1 {
        font-size: 1.8em;
    }
    .card-section {
        padding: 20px;
    }
    .calculate-btn {
        width: 100%;
        padding: 15px;
    }
}