/* Estimate Controls CSS */

/* ---- Div-based line item grid ---- */
.estimate-grid {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 8px;
    overflow-x: auto;
}

.estimate-grid-header {
    display: grid;
    grid-template-columns: 100px 30px 1fr 120px 80px 100px 90px 100px 50px 40px;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid #dee2e6;
}

.estimate-grid-header > div {
    padding: 4px 6px;
    white-space: nowrap;
}

.estimate-line-row {
    display: grid;
    grid-template-columns: 100px 30px 1fr 120px 80px 100px 90px 100px 50px 40px;
    align-items: center;
}

.estimate-line-row:hover {
    background-color: #f0f8ff;
}

.estimate-line-row > div {
    padding: 2px 4px;
}

/* Read-only grid: no flat-rate button or delete columns */
.estimate-grid-readonly .estimate-grid-header {
    grid-template-columns: 100px 1fr 120px 80px 100px 90px 100px 50px;
}

.estimate-grid-readonly .estimate-line-row {
    grid-template-columns: 100px 1fr 120px 80px 100px 90px 100px 50px;
}

.estimate-grid-empty {
    padding: 12px;
    text-align: center;
    color: #6c757d;
}

/* Column helpers */
.eg-type {
    display: flex;
    align-items: center;
    padding: 2px 4px;
}

.eg-fr {
    display: flex;
    align-items: center;
    justify-content: center;
}

.eg-fr .icon-btn {
    color: #0d6efd;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.eg-del {
    display: flex;
    align-items: center;
    justify-content: center;
}

.eg-del .icon-btn {
    color: gray;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.eg-tax {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Summary card */
.estimate-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding-right: 20px;
}

.estimate-summary-line {
    display: flex;
    gap: 8px;
    font-size: 0.95rem;
    padding: 2px 0;
}

.estimate-summary-line span:first-child {
    min-width: 70px;
    text-align: right;
}

/* Inline inputs */
.estimate-inline-input {
    border: 1px solid #ddd;
    padding: 2px 6px;
    font-size: 0.85rem;
    height: 28px;
    width: 100%;
}

.estimate-inline-input:focus {
    border-color: var(--rtblue);
    box-shadow: 0 0 0 1px var(--rtblue);
    outline: none;
}

.eg-travel-info {
    font-size: 0.85rem;
    color: #555;
    white-space: nowrap;
}


/* ---- Document-style layout ---- */

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid var(--rtblue);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.doc-header-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.doc-header-left h3 {
    color: var(--rtblue);
    font-weight: 700;
    font-size: 1.6rem;
    margin: 0;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.doc-header-left .doc-number {
    font-size: 1.1rem;
    color: #555;
    font-weight: 500;
}

.doc-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.doc-status-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.doc-status-draft {
    background-color: #fff3cd;
    color: #856404;
}

.doc-status-sent, .doc-status-pending {
    background-color: #cce5ff;
    color: #004085;
}

.doc-status-accepted, .doc-status-paid {
    background-color: #d4edda;
    color: #155724;
}

.doc-status-declined, .doc-status-cancelled, .doc-status-overdue {
    background-color: #f8d7da;
    color: #721c24;
}

.doc-info-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 12px;
}

.doc-info-section .doc-info-left,
.doc-info-section .doc-info-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.doc-info-right {
    border-left: 1px solid #dee2e6;
    padding-left: 20px;
    position: relative;
}

.doc-info-right-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.doc-info-number {
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    letter-spacing: 0.5px;
}

.doc-info-qb-btn {
    margin-left: auto;
}

.doc-info-card {
    position: relative;
}

.doc-qb-corner-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 1;
}

.doc-field-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-field-row label {
    min-width: 100px;
    margin: 0;
}

.doc-search-btn {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rtblue);
    cursor: pointer;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
}

    .doc-search-btn:hover {
        color: var(--rtblue-dark, #0056b3);
    }

.doc-bottom-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.doc-notes-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.doc-notes-area h6 {
    color: var(--rtblue);
    font-weight: 600;
    margin: 0 0 4px 0;
}

.doc-totals-area {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
}

.doc-totals-table {
    width: 260px;
    border-collapse: collapse;
}

.doc-totals-table tr td {
    padding: 6px 10px;
    font-size: 0.95rem;
}

.doc-totals-table tr td:first-child {
    text-align: right;
    font-weight: 500;
    color: #555;
}

.doc-totals-table tr td:last-child {
    text-align: right;
    min-width: 100px;
}

.doc-totals-table tr.doc-total-grand {
    border-top: 2px solid var(--rtblue);
}

.doc-totals-table tr.doc-total-grand td {
    font-weight: 700;
    font-size: 1.1rem;
    color: #333;
    padding-top: 10px;
}

.doc-estimate-badge {
    font-size: 0.8rem;
    padding: 2px 10px;
    border-radius: 10px;
    background-color: #d1ecf1;
    color: #0c5460;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .doc-info-section {
        grid-template-columns: 1fr;
    }

    .doc-info-right {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid #dee2e6;
        padding-top: 12px;
    }

    .doc-bottom-section {
        grid-template-columns: 1fr;
    }
}

/* Insufficient stock warning */
.eg-insufficient-stock,
.eg-insufficient-stock:focus {
    color: darkred !important;
    font-weight: 700;
}
