/* ==========================================================
   estimation.css
   Stylesheet for Amalorpavam Constructions – estimation.php
   Uses CSS custom properties so colors/spacing are defined
   once and referenced everywhere (change one value, whole
   page updates — no hunting through duplicated hex codes).
   ========================================================== */

:root {
    --est-blue: #1a5fb4;
    --est-blue-dark: #0d3b7a;
    --est-blue-light: #eaf2fb;
    --est-blue-border: #c5d9f5;
    --est-navy: #0a1628;
    --est-navy-alt: #1f2a3f;
    --est-gray-bg: #f6f8fa;
    --est-gray-border: #dde0e3;
    --est-gray-border-light: #ebedf0;
    --est-text-muted: #777;
    --est-text-body: #444;
    --est-warn-bg: #fff3cd;
    --est-warn-border: #ffc107;
    --est-radius-lg: 10px;
    --est-radius-md: 8px;
    --est-radius-sm: 6px;
    --est-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --est-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.03);
}

/* ===== RESET ===== */
.estimation-page * {
    box-sizing: border-box;
}

.estimation-page .estimation-container {
    max-width: 1000px;
    width: 100%;
    background: white;
    padding: 25px 30px;
    border-radius: var(--est-radius-lg);
    box-shadow: var(--est-shadow);
}

/* ===== HEADER ===== */
.estimation-page .header {
    text-align: center;
    border-bottom: 2px solid var(--est-blue);
    padding-bottom: 8px;
    margin-bottom: 18px;
}

.estimation-page .header img {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 220px;
    object-fit: contain;
    margin: 0 0 6px 0;
}

/* Hidden so the header image is the sole header */
.estimation-page .header h1,
.estimation-page .header .sub {
    display: none;
}

.estimation-page .header .date {
    color: var(--est-blue);
    font-size: 12px;
    margin-top: 3px;
}

/* ===== INPUT ===== */
.estimation-page .input-box {
    background: var(--est-blue-light);
    padding: 18px 20px;
    border-radius: var(--est-radius-md);
    max-width: 480px;
    margin: 0 auto 20px auto;
    border: 1px solid var(--est-blue-border);
}

.estimation-page .input-box label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 15px;
}

.estimation-page .input-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.estimation-page .input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #ccc;
    border-radius: var(--est-radius-sm);
    font-size: 16px;
}

.estimation-page .input-row input:focus {
    outline: none;
    border-color: var(--est-blue);
}

.estimation-page .input-row button {
    background: var(--est-blue);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: var(--est-radius-sm);
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.estimation-page .input-row button:hover {
    background: var(--est-blue-dark);
}

.estimation-page .input-box .note {
    font-size: 12px;
    color: var(--est-text-muted);
    margin-top: 8px;
}

/* ===== RESULTS (hidden initially) ===== */
.estimation-page .results {
    display: none;
    animation: estFadeIn 0.3s ease;
}

@keyframes estFadeIn {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ===== SUMMARY CARDS ===== */
.estimation-page .summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.estimation-page .summary-card {
    padding: 14px 10px;
    border-radius: var(--est-radius-md);
    text-align: center;
    border: 1px solid var(--est-gray-border);
}

.estimation-page .summary-card.blue {
    background: var(--est-blue-light);
    border-color: var(--est-blue-border);
}

.estimation-page .summary-card.gray {
    background: var(--est-gray-bg);
}

.estimation-page .summary-card .label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--est-blue);
    letter-spacing: 0.5px;
}

.estimation-page .summary-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--est-navy);
    line-height: 1.2;
}

/* ===== CALCULATOR SECTION ===== */
.estimation-page .calculator-section {
    background: #ffffff;
    border: 1px solid var(--est-gray-border);
    border-radius: 12px;
    padding: 24px 28px;
    box-shadow: var(--est-shadow-sm);
    margin-bottom: 24px;
}

/* ===== GALLERY ===== */
.estimation-page .gallery-section {
    margin-top: 12px;
    background: #ffffff;
    border: 1px solid var(--est-gray-border);
    border-radius: 12px;
    padding: 22px 24px;
    box-shadow: var(--est-shadow-sm);
}

.estimation-page .gallery-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--est-navy);
    text-align: center;
    margin-bottom: 16px;
}

.estimation-page .gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.estimation-page .gallery-card {
    position: relative;
    border-radius: var(--est-radius-lg);
    overflow: hidden;
    border: 1px solid var(--est-gray-border);
    background: #ffffff;
}

/* Ghost overlay — see the matching comment in css/style.css for what this
   does and does not protect against. */
.estimation-page .gallery-card::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
}

.estimation-page .gallery-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.estimation-page .gallery-card:hover img {
    transform: scale(1.05);
}

/* ===== INFO BOX ===== */
.estimation-page .info-box {
    background: var(--est-warn-bg);
    border-left: 5px solid var(--est-warn-border);
    padding: 10px 16px;
    margin-bottom: 14px;
    border-radius: 0 6px 6px 0;
}

.estimation-page .info-box .title {
    font-weight: 700;
    font-size: 14px;
    color: var(--est-navy);
}

.estimation-page .info-box .text {
    font-size: 13px;
    color: var(--est-text-body);
    margin-top: 3px;
}

/* ===== TOTAL SUMMARY ===== */
.estimation-page .total-summary {
    background: var(--est-blue-light);
    border: 2px solid var(--est-blue);
    padding: 10px 16px;
    border-radius: var(--est-radius-md);
    margin-bottom: 14px;
}

.estimation-page .total-summary .title {
    font-weight: 700;
    font-size: 14px;
    color: var(--est-navy);
}

.estimation-page .total-summary .line {
    font-size: 13px;
    color: #1f2a3a;
    margin-top: 2px;
}

.estimation-page .total-summary .grand {
    font-size: 22px;
    font-weight: 700;
    color: var(--est-blue);
    margin-top: 4px;
}

/* ===== TABLE ===== */
.estimation-page .table-section h3 {
    font-size: 16px;
    margin-bottom: 6px;
    color: var(--est-navy);
}

.estimation-page .table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--est-gray-border);
    border-radius: var(--est-radius-md);
}

.estimation-page table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.estimation-page table th {
    background: var(--est-gray-bg);
    padding: 8px 12px;
    border-bottom: 2px solid var(--est-gray-border);
    text-align: left;
    font-weight: 600;
    color: var(--est-navy);
}

.estimation-page table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--est-gray-border-light);
}

.estimation-page table tr:last-child td {
    border-bottom: none;
}

.estimation-page .text-right { text-align: right; }
.estimation-page .text-center { text-align: center; }

.estimation-page .total-row {
    background: var(--est-blue-light) !important;
    font-weight: 700;
    border-top: 2px solid var(--est-blue);
}

.estimation-page .total-row td {
    padding: 10px 12px;
    color: var(--est-navy);
}

/* ===== SIGNATURES ===== */
.estimation-page .signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--est-gray-border);
}

.estimation-page .signature-box {
    width: 45%;
}

.estimation-page .signature-left { text-align: left; }
.estimation-page .signature-right { text-align: right; }

.estimation-page .signature-box .line {
    border-top: 1.5px solid var(--est-navy);
    margin-top: 20px;
    padding-top: 4px;
    font-size: 11px;
    color: #666;
}

/* ===== BUTTON ===== */
.estimation-page .btn-print {
    width: 100%;
    padding: 12px;
    background: var(--est-navy);
    color: white;
    border: none;
    border-radius: var(--est-radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 18px;
    transition: background 0.2s;
}

.estimation-page .btn-print:hover {
    background: var(--est-navy-alt);
}

.estimation-page .print-only {
    display: none;
}

@media (max-width:900px) {
    .estimation-page .estimation-container {
        padding: 20px 18px;
    }

    .estimation-page .calculator-section {
        padding: 20px 18px;
    }

    .estimation-page .gallery-section {
        padding: 18px 16px;
    }

    .estimation-page .summary-grid {
        grid-template-columns: 1fr;
    }

    .estimation-page .summary-card .value {
        font-size: 24px;
    }
}

@media (max-width:640px) {
    .estimation-page .input-box {
        padding: 14px;
    }

    .estimation-page .input-row {
        flex-direction: column;
    }

    .estimation-page .input-row input,
    .estimation-page .input-row button {
        width: 100%;
    }

    .estimation-page .btn-print {
        padding: 12px 14px;
        font-size: 14px;
    }

    .estimation-page .gallery-grid {
        grid-template-columns: 1fr;
    }

    .estimation-page .gallery-card img {
        height: 160px;
    }

    .estimation-page .signatures {
        flex-direction: column;
        gap: 16px;
    }

    .estimation-page .signature-box {
        width: 100%;
        text-align: left;
    }
}

/* ============================================================
   PRINT STYLES – A4, real @page margin.
   html/body width is intentionally NOT set: when @page defines
   a 15mm margin, Chrome's printable content box is already
   210mm - 15mm - 15mm = 180mm wide. Forcing html/body to a
   fixed 210mm made them wider than the box they render into,
   which caused clipped content / unwanted overflow to a second
   page. Letting html/body size naturally to the @page content
   box is correct.
   ============================================================ */
@media print {
    body > header,
    body > nav,
    body > footer,
    nav.nav,
    footer.footer {
        display: none !important;
    }

    html, body {
        background: white;
        padding: 0;
        margin: 0;
    }

    .estimation-page .estimation-container {
        max-width: 100%;
        width: 100%;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .estimation-page .input-box,
    .estimation-page .btn-print {
        display: none !important;
    }

    .estimation-page .estimation-body {
        display: block;
    }

    .estimation-page .results {
        display: block !important;
        animation: none !important;
    }

    .estimation-page .signatures {
        margin-top: 12pt !important;
    }

    .estimation-page .print-only {
        display: block !important;
    }

    .estimation-page .signatures.print-only {
        display: flex !important;
    }

    /* .header h1 / .header .sub have no print override here —
       they are permanently display:none in the base rule above,
       so a font-size override for them would be dead code. */
    .estimation-page .header .date { font-size: 9pt; }
    .estimation-page .header { padding-bottom: 6pt; margin-bottom: 8pt; }
    .estimation-page .header img { max-height: 45mm; width: 100%; height: auto; object-fit: contain; }

    .estimation-page .summary-grid { gap: 8pt; margin-bottom: 10pt; }
    .estimation-page .summary-card { padding: 8pt 6pt; }
    .estimation-page .summary-card .value { font-size: 22pt; }
    .estimation-page .summary-card .label { font-size: 9pt; }

    .estimation-page .info-box { padding: 6pt 10pt; margin-bottom: 8pt; }
    .estimation-page .info-box .title { font-size: 11pt; }
    .estimation-page .info-box .text { font-size: 9.5pt; }

    .estimation-page .total-summary { padding: 6pt 10pt; margin-bottom: 8pt; }
    .estimation-page .total-summary .title { font-size: 11pt; }
    .estimation-page .total-summary .line { font-size: 9.5pt; }
    .estimation-page .total-summary .grand { font-size: 16pt; margin-top: 2pt; }

    .estimation-page .table-section h3 { font-size: 13pt; margin-bottom: 4pt; }
    .estimation-page table { font-size: 10.5pt; }
    .estimation-page table th,
    .estimation-page table td { padding: 5pt 8pt; }
    .estimation-page .total-row td { padding: 6pt 8pt; }

    .estimation-page table td:first-child {
        max-width: 65mm;
        word-break: break-word;
    }

    .estimation-page .signatures { margin-top: 14pt; padding-top: 8pt; }
    .estimation-page .signature-box .line { margin-top: 14pt; font-size: 10pt; }

    /* Keep small blocks intact across a page break. Signatures are
       intentionally NOT forced to avoid-break: on some content
       lengths that rule pushed the whole block onto a near-empty
       second page. */
    .estimation-page .header,
    .estimation-page .summary-grid,
    .estimation-page .info-box,
    .estimation-page .total-summary {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .estimation-page .signatures {
        page-break-inside: avoid;
        break-inside: avoid;
        page-break-before: avoid;
        break-before: avoid;
    }

    .estimation-page table thead {
        display: table-header-group;
    }

    /* Without this, Chrome treats <tfoot> as a repeating footer
       group and reprints the total row on every page the table
       spans. */
    .estimation-page table tfoot {
        display: table-row-group;
    }

    .estimation-page tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .estimation-page .no-print {
        display: none !important;
    }

    @page {
        size: A4;
        margin: 15mm;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 960px) {
    .estimation-page .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .estimation-page .gallery-card img { height: 160px; }
}

@media (max-width: 720px) {
    .estimation-page .gallery-grid { grid-template-columns: 1fr; }
    .estimation-page .gallery-card img { height: 220px; }
    .estimation-page .gallery-title { font-size: 16px; }
}

@media (max-width: 600px) {
    .estimation-page .summary-grid { grid-template-columns: 1fr; }
    .estimation-page .input-row { flex-direction: column; }
    .estimation-page .input-row input { min-width: unset; }
    .estimation-page .gallery-card img { height: 200px; }
}
