/* Energy Savings Calculator Styles */

/* Calculator group wrapper - background */
.calc-group {
    background: #f2f2f2;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    overflow-x: auto;
}

/* Calculator table */
.calc-table {
    border-collapse: collapse;
    font-size: 11px;
    font-family: 'Open Sans', sans-serif;
    margin-bottom: 30px;
    width: 100%;
}

.calc-table th,
.calc-table td {
    border: 1px solid #999;
    padding: 2px 4px;
    vertical-align: middle;
    text-align: center;
}

/* Headers - base */
.calc-table th {
    font-weight: 700;
    font-size: 10px;
    white-space: normal;
    min-width: 46px;
}

/* Group-specific header colors */
#group-apgaismojums .calc-table th { background-color: #FBF3C5; }
#group-apgaismojums .calc-table th.result { background-color: #F6E57E; }

#group-apkure .calc-table th { background-color: #F2DBDB; }
#group-apkure .calc-table th.result { background-color: #D99594; }

#group-iekartas .calc-table th { background-color: #C6D9F0; }
#group-iekartas .calc-table th.result { background-color: #548DD4; }

#group-transports .calc-table th { background-color: #EAF1DD; }
#group-transports .calc-table th.result { background-color: #C2D69B; }

#group-info .calc-table th { background-color: #FDE9D9; }
#group-info .calc-table th.result { background-color: #FABF8F; }

#group-ventilacija .calc-table th { background-color: #E5DFEC; }
#group-ventilacija .calc-table th.result { background-color: #B2A1C7; }

/* MWh header - blue (higher specificity to override group id-based colors) */
.calc-table th.mwh[class] {
    background-color: #36B8CA !important;
    color: #000 !important;
}

/* Readonly cells - gray description */
.calc-table td.readonly {
    background-color: #D8D8D8;
    text-align: left;
}

/* Readonly cells with default values - light gray */
.calc-table td.default {
    background-color: #D9D9D9;
    text-align: right;
}

/* Editable cells */
.calc-table td.editable {
    background-color: #fff;
    padding: 2px;
}

.calc-table td.editable input,
.calc-table td.editable select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    padding: 3px 4px;
    text-align: right;
    font-size: 12px;
    font-family: 'Open Sans', sans-serif;
    background-color: #fff;
}

.calc-table td.editable select {
    text-align: left;
}

.pct-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
}

.pct-wrap input,
.pct-wrap .numeric-wrap {
    flex: 1;
    min-width: 0;
}

/* SDVD-4353: custom numeric spinner buttons (shown on hover) */
/* SDVD-4353: кастомні кнопки ▲/▼ для числових інпутів (видимі на hover) */
/*
 * CSS Grid layout: input on the left (spans 2 rows), spinner buttons stacked
 * on the right. Avoids fragile absolute-height math and always sits IN-LINE
 * with the input (no wrapping below).
 * Layout на CSS Grid: інпут ліворуч (обидва рядки), дві кнопки праворуч.
 */
.numeric-wrap {
    display: inline-grid;
    /* Symmetric layout: 14px gutter on the left matches the 14px spinner
     * column on the right, so the input stays visually centered in the cell.
     * Симетрично: 14px-gutter ліворуч дзеркалить 14px-кнопки праворуч. */
    grid-template-columns: 14px 1fr 14px;
    grid-template-rows: 1fr 1fr;
    width: 100%;
    min-height: 22px;
    vertical-align: middle;
    position: relative;
}

.calc-table td.editable .numeric-wrap > input.numeric-input {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.numeric-spin {
    padding: 0;
    margin: 0;
    border: 1px solid #bbb;
    background: #f2f2f2;
    color: #333;
    font-size: 7px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.12s ease-in-out;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
}

.numeric-spin.up   { grid-column: 3; grid-row: 1; border-left: none; border-bottom: none; }
.numeric-spin.down { grid-column: 3; grid-row: 2; border-left: none; }

.numeric-wrap:hover .numeric-spin,
.numeric-wrap:focus-within .numeric-spin {
    opacity: 1;
}

.numeric-spin:hover  { background: #e6e6e6; }
.numeric-spin:active { background: #d4d4d4; }

.pct-wrap span {
    flex-shrink: 0;
    font-size: 12px;
}

.calc-table td.editable input:focus,
.calc-table td.editable select:focus {
    border-color: #44366c;
    outline: none;
}

/* Formula/computed cells - gray */
.calc-table td.formula {
    background-color: #D8D8D8;
    text-align: right;
    font-weight: 600;
}

/* Lifecycle column - slightly different gray */
.calc-table td.lifecycle {
    background-color: #D9D9D9;
    text-align: right;
}

/* Separator column between main table and MWh */
.calc-table .calc-separator {
    border: none;
    background: transparent;
    width: 10px;
    min-width: 10px;
    padding: 0;
}

/* Empty merged cells (K-M when not used) */
.calc-table td.empty-merge {
    background-color: #D8D8D8;
    border-left: 1px solid #999;
    border-right: 1px solid #999;
}

/* Number cell - row number column */
.calc-table td.row-num {
    background: transparent;
    border: none;
    text-align: right;
    font-weight: 600;
    padding-right: 8px;
    min-width: 20px;
}

/* Sub-header row (e.g. Dimmēšana / Intervālu taimeri / Kustību sensori) */
.calc-table th.sub-header {
    background-color: #FBF3C5;
    font-size: 10px;
}

/* Light-weight header (long descriptive text) */
.calc-table th.light {
    font-weight: normal;
}

/* Print button */
.calc-print-btn {
    margin-top: 10px;
    margin-bottom: 30px;
    padding: 8px 24px;
    background-color: #44366c;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Open Sans', sans-serif;
}

.calc-print-btn:hover {
    background-color: #352a55;
}

.calc-print-btn.loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

.calc-print-btn.loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    vertical-align: middle;
    animation: calc-spin 0.6s linear infinite;
}

@keyframes calc-spin {
    to { transform: rotate(360deg); }
}

/* Calculator section title */
.calc-section-title {
    font-size: 14px;
    font-weight: 600;
    margin: 20px 0 4px 0;
    color: #3d3d3d;
}

/* Calculator section description AND subsection title — unified look:
 * any text directly above a calculation table renders identically across
 * all 6 groups (apgaismojums, apkure, iekartas, transports, info,
 * ventilacija). The subsection h4 used to have its own bold/indented
 * style; merged here so "Nerenovētas vienģimenes mājas" (under 7. Pieslēgums)
 * and "Vienģimenes mājas" (under 2. Siltumsūkņi) match the plain section
 * descriptions visually. */
.calc-section-desc,
.calc-subsection-title {
    font-family: 'Open Sans', sans-serif;
    font-size: 12px;
    font-weight: normal;
    color: #666;
    margin: 0 0 8px 0;
    text-align: left;
}

/* Tooltip icon in table headers */
.calc-tooltip {
    position: relative;
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    font-size: 10px;
    font-style: italic;
    font-weight: 700;
    background-color: #888;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    vertical-align: middle;
}

.calc-tooltip .calc-tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    font-size: 11px;
    font-style: normal;
    font-weight: 400;
    text-align: left;
    white-space: normal;
    width: 220px;
    padding: 6px 8px;
    border-radius: 4px;
    z-index: 100;
    transition: opacity 0.2s;
}

.calc-tooltip:hover .calc-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Info reference table (non-editable, read-only data) */
.calc-info-table th {
    background-color: #fff !important;
}

.calc-info-table td {
    background-color: #fff;
    text-align: center;
}

.calc-info-table td:nth-child(2) {
    text-align: left;
}

/* Formula fractions */
.formula {
    font-style: italic;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
}

.fraction .numerator {
    border-bottom: 1px solid currentColor;
    padding: 0 4px 2px;
}

.fraction .denominator {
    padding: 2px 4px 0;
}
