/* =================================================================
   Page-Specific Styles for Solar Calculator
   ================================================================= */

/* --- Wrapper and Layout --- */
.calculator-wrapper {
    background-color: var(--card-bg);
    padding: clamp(1rem, 4vw, 2rem);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
}
:root.dark-mode .calculator-wrapper {
    background-color: var(--card-bg-dark);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border-color: var(--border-color-dark);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive::-webkit-scrollbar {
    height: 8px;
}
.table-responsive::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}
:root.dark-mode .table-responsive::-webkit-scrollbar-track {
    background: var(--bg-light-dark);
}
:root.dark-mode .table-responsive::-webkit-scrollbar-thumb {
    background-color: var(--border-color-dark);
}

/* --- Table Styling --- */
.calculator-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
    table-layout: auto;
}
.calculator-table th,
.calculator-table td {
    padding: 1rem 0.75rem;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}
:root.dark-mode .calculator-table th,
:root.dark-mode .calculator-table td {
    border-bottom-color: var(--border-color-dark);
}

/* Table Header */
.calculator-table thead {
    background-color: rgba(var(--accent-rgb), 0.1);
    border-bottom: 3px solid var(--accent-color);
}
:root.dark-mode .calculator-table thead {
    background-color: rgba(var(--accent-rgb-dark), 0.15);
    border-bottom-color: var(--accent-color-dark);
}

.calculator-table th {
    font-weight: 700;
    color: var(--accent-dark);
    white-space: nowrap;
}
:root.dark-mode .calculator-table th {
    color: var(--accent-color-dark);
}


/* Table Body */
.calculator-row:nth-child(even) {
    background-color: rgba(var(--primary-rgb), 0.02);
}
:root.dark-mode .calculator-row:nth-child(even) {
    background-color: rgba(var(--primary-rgb-dark), 0.03);
}

/* Table Footer (Totals) */
.calculator-table tfoot {
    background-color: rgba(var(--secondary-rgb), 0.15);
    border-top: 3px solid var(--secondary-color);
    font-weight: 700;
    color: var(--secondary-dark);
}
:root.dark-mode .calculator-table tfoot {
    background-color: rgba(var(--secondary-rgb-dark), 0.15);
    border-top-color: var(--secondary-color-dark);
    color: var(--secondary-color-dark);
}
.calculator-table tfoot td {
    font-size: 1.1rem;
}

/* --- Form Fields & Buttons --- */
.calculator-table .form-control {
    padding: 0.5rem 0.75rem;
    min-width: 70px;
    height: auto;
    text-align: center;
    background-color: var(--bg-color);
}
.calculator-table input[type="text"].form-control {
    min-width: 120px;
}
:root.dark-mode .calculator-table .form-control {
    background-color: var(--bg-light-dark);
}

.output-field {
    background-color: rgba(var(--secondary-rgb), 0.05) !important;
    border-color: rgba(var(--secondary-rgb), 0.2) !important;
    font-weight: 600;
    color: var(--secondary-dark) !important;
    cursor: not-allowed;
}
:root.dark-mode .output-field {
    background-color: rgba(var(--secondary-rgb-dark), 0.1) !important;
    border-color: rgba(var(--secondary-rgb-dark), 0.3) !important;
    color: var(--secondary-light-dark) !important;
}

.delete-row-btn {
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    line-height: 1;
}

.calculator-actions {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    border-top: 1px dashed var(--border-color);
    padding-top: 2rem;
}
:root.dark-mode .calculator-actions {
    border-top-color: var(--border-color-dark);
}


/* --- Results Summary Section --- */
.results-summary-wrapper {
    margin-top: 3rem;
    background: linear-gradient(135deg, var(--bg-color), var(--bg-light));
    border: 1px solid var(--border-color);
    border-top: 5px solid var(--primary-color);
    padding: clamp(1.5rem, 5vw, 2.5rem);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.05);
}
:root.dark-mode .results-summary-wrapper {
     background: linear-gradient(135deg, var(--bg-color-dark), var(--bg-light-dark));
     border-color: var(--border-color-dark);
     border-top-color: var(--primary-color-dark);
     box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.summary-title {
    text-align: center;
    color: var(--primary-dark);
}
:root.dark-mode .summary-title {
    color: var(--primary-light-dark);
}
.summary-description {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 2.5rem auto;
    color: var(--text-muted-color);
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2rem;
}
.summary-item {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
    transition: var(--transition-base);
}
.summary-item:hover {
    transform: translateY(-8px);
    box-shadow: var(--box-shadow-hover);
}
:root.dark-mode .summary-item {
     background-color: var(--card-bg-dark);
     border-color: var(--border-color-dark);
     box-shadow: var(--box-shadow-dark);
}
:root.dark-mode .summary-item:hover {
     box-shadow: var(--box-shadow-hover-dark);
}
.summary-item i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: inline-block;
    color: var(--accent-color);
}
:root.dark-mode .summary-item i {
    color: var(--accent-color-dark);
}
.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
    word-break: break-all;
}
:root.dark-mode .summary-value {
    color: var(--primary-light-dark);
}
.summary-label {
    font-size: 1rem;
    color: var(--text-muted-color);
    font-weight: 500;
}
:root.dark-mode .summary-label {
     color: var(--text-muted-color-dark);
}

/* --- Responsive Styles for Mobile --- */
@media (max-width: 991px) {
    .table-responsive {
        overflow-x: unset;
    }
    .calculator-table {
        width: 100%;
        min-width: unset;
        table-layout: auto;
    }
    .calculator-table thead {
        display: none;
    }
    .calculator-table,
    .calculator-table tbody,
    .calculator-table tr,
    .calculator-table td {
        display: block;
        width: 100%;
    }
    .calculator-table tr {
        margin-bottom: 2rem;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: 1rem;
        background-color: var(--card-bg) !important; /* Override even/odd styling */
    }
    :root.dark-mode .calculator-table tr {
        border-color: var(--border-color-dark);
        background-color: var(--card-bg-dark) !important;
    }
    .calculator-table td {
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: 1rem;
        align-items: center;
        text-align: right;
        padding: 0.75rem 0.5rem;
        border: none;
        border-bottom: 1px dashed rgba(var(--primary-rgb), 0.1);
    }
    html[lang="en"] .calculator-table td {
        text-align: left;
    }
    .calculator-table td:last-child {
        border-bottom: none;
    }
    .calculator-table td::before {
        content: attr(data-label-ar);
        font-weight: 600;
        color: var(--text-color);
        padding-right: 1rem;
    }
     html[lang="en"] .calculator-table td::before {
        content: attr(data-label-en);
        padding-left: 1rem;
        padding-right: 0;
    }
    :root.dark-mode .calculator-table td::before {
        color: var(--text-color-dark);
    }

    .calculator-table td:nth-child(6), /* Hide calculated fields on mobile */
    .calculator-table td:nth-child(7),
    .calculator-table td:nth-child(8),
    .calculator-table td:nth-child(9) {
        display: none;
    }
    
    .delete-row-btn {
        grid-column: 2 / 3; /* Take the full second column */
    }

    /* Footer on Mobile */
    .calculator-table tfoot tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        padding: 1.5rem;
        border-radius: var(--border-radius);
        background-color: var(--bg-light) !important;
    }
    :root.dark-mode .calculator-table tfoot tr {
        background-color: var(--bg-light-dark) !important;
    }
    .calculator-table tfoot td {
        grid-template-columns: 1fr;
        text-align: center;
        border: none;
        background-color: var(--card-bg);
        padding: 1rem;
        border-radius: var(--border-radius);
    }
    :root.dark-mode .calculator-table tfoot td {
         background-color: var(--card-bg-dark);
    }
    .calculator-table tfoot td::before {
        content: attr(data-label-ar);
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
        font-weight: 500;
        color: var(--text-muted-color);
    }
     html[lang="en"] .calculator-table tfoot td::before {
         content: attr(data-label-en);
    }
     :root.dark-mode .calculator-table tfoot td::before {
        color: var(--text-muted-color-dark);
     }
    .d-none.d-md-table-cell {
        display: none !important;
    }
}