/* Rich text description editor */
.invoice-description-field .invoice-rich-editor {
    min-height: 160px;
}

.invoice-description-field .ql-toolbar.ql-snow {
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
    background: #fff5eb;
}

.invoice-description-field .ql-container.ql-snow {
    border-bottom-left-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    font-size: 1rem;
}

.company-default-description-field .invoice-rich-editor .ql-container.ql-snow {
    min-height: 280px;
}

.company-default-description-field .invoice-rich-editor .ql-editor {
    min-height: 240px;
}

.company-default-description-field .ql-toolbar.ql-snow {
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
    background: #fff5eb;
}

.company-default-description-field .ql-container.ql-snow {
    border-bottom-left-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    font-size: 1rem;
}

/* Line items table */
#line-items-table input[readonly] {
    cursor: default;
}

#line-items-table .remove-row {
    line-height: 1;
    padding: 0.2rem 0.5rem;
    min-width: 2rem;
}

#line-items-table tr.line-item-group-header td.group-header-cell {
    background: #ffffff;
    border-top: 2px solid var(--bs-primary);
    padding: 0.75rem;
}

#line-items-table tr.line-item-group-header .group-name {
    font-weight: 600;
}

#line-items-table th.col-serial,
#line-items-table td.serial-cell {
    width: 2.75rem;
    max-width: 3rem;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    text-align: center;
    vertical-align: middle;
}

#line-items-table .serial-no-display {
    display: inline-block;
    min-width: 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--bs-secondary-color);
    line-height: 1.5;
}

/* Mobile: stack each row as a card */
@media (max-width: 767.98px) {
    .line-items-wrapper {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }

    #line-items-table thead {
        display: none;
    }

    #line-items-table,
    #line-items-table tbody,
    #line-items-table tr.line-item-row,
    #line-items-table td {
        display: block;
        width: 100%;
    }

    #line-items-table tr.line-item-group-header {
        display: block;
        width: 100%;
        border: 1px solid var(--bs-primary);
        border-radius: 0.5rem 0.5rem 0 0;
        margin-top: 1rem;
        margin-bottom: 0;
        padding: 0.75rem;
        background: #ffffff;
    }

    #line-items-table tr.line-item-group-header td {
        border: none;
        padding: 0;
    }

    #line-items-table tr.line-item-group-header td::before {
        display: none;
    }

    #line-items-table tr.line-item-row {
        border: 1px solid var(--bs-border-color);
        border-top: none;
        border-radius: 0 0 0.5rem 0.5rem;
        margin-bottom: 1rem;
        padding: 0.75rem;
        background: #fff;
        display: flex;
        flex-wrap: wrap;
        column-gap: 0.5rem;
    }

    #line-items-table tr.line-item-row + tr.line-item-row {
        border-radius: 0;
        margin-bottom: 0;
        border-top: 1px dashed var(--bs-border-color);
    }

    #line-items-table tr.line-item-group-header + tr.line-item-row:has(+ tr.line-item-row),
    #line-items-table tr.line-item-row:has(+ tr.line-item-row) {
        border-radius: 0;
        margin-bottom: 0;
    }

    #line-items-table td {
        border: none;
        padding: 0.35rem 0;
        flex: 0 0 100%;
        width: 100%;
    }

    #line-items-table td.line-item-dim-cell {
        flex: 0 0 calc(50% - 0.25rem);
        width: calc(50% - 0.25rem);
    }

    #line-items-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--bs-secondary-color);
        margin-bottom: 0.2rem;
    }

    #line-items-table td.row-actions::before {
        display: none;
    }

    #line-items-table td.row-actions {
        text-align: right;
        padding-top: 0.5rem;
    }

    #line-items-table td.serial-cell {
        display: flex;
        align-items: center;
        padding-bottom: 0.5rem;
        margin-bottom: 0.35rem;
        border-bottom: 1px solid var(--bs-border-color);
    }

    #line-items-table td.serial-cell::before {
        display: none;
    }

    #line-items-table .serial-no-display {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.85rem;
        height: 1.85rem;
        min-width: 1.85rem;
        border: 2px solid var(--bs-primary);
        border-radius: 50%;
        font-size: 0.85rem;
        font-weight: 700;
        color: var(--bs-primary);
        background-color: rgba(255, 112, 0, 0.12);
        line-height: 1;
    }

    #line-items-table .form-control-sm {
        font-size: 1rem;
        padding: 0.5rem 0.65rem;
    }
}

/* Invoice list mobile */
.invoice-list-mobile .grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.fab-create {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1030;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.2);
}

/* Touch-friendly form actions */
@media (max-width: 575.98px) {
    .form-actions .btn-lg {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .navbar-brand {
        font-size: 1rem;
    }
}

/* Sticky nav safe area for FAB */
@media (max-width: 767.98px) {
    main.container {
        padding-bottom: 5rem !important;
    }
}

/* Pagination */
.invoice-pagination .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 0;
}

.invoice-pagination .page-link {
    min-width: 2.5rem;
    text-align: center;
}

@media (max-width: 575.98px) {
    .invoice-pagination .pagination {
        font-size: 0.875rem;
    }

    .invoice-pagination .page-link {
        padding: 0.35rem 0.6rem;
        min-width: 2.25rem;
    }
}
