/* SAP Business One Theme for Filament Invoices */

/* Scope all overrides to only apply when the custom SAP wrapper is present on the page */

body:has(.sap-desktop-wrapper) {
    background-color: #5b7da8 !important;
    overflow-x: hidden !important;
}

body:has(.sap-desktop-wrapper) .fi-layout,
body:has(.sap-desktop-wrapper) .fi-main-ctn,
body:has(.sap-desktop-wrapper) .fi-main,
body:has(.sap-desktop-wrapper) .fi-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
}

body:has(.sap-desktop-wrapper) .fi-sidebar,
body:has(.sap-desktop-wrapper) .fi-topbar,
body:has(.sap-desktop-wrapper) .fi-header,
body:has(.sap-desktop-wrapper) .fi-breadcrumbs {
    display: none !important;
}

/* Scoped SAP Business One Desktop Styles */
.sap-desktop-wrapper {
    width: 100% !important;
    min-height: 100vh !important;
    background: linear-gradient(135deg, #5b7da8 0%, #2e4d75 100%) !important;
    padding: 12px !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
}

.sap-window {
    background-color: #ebecee;
    border: 2px solid #0f243e;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* SAP Header Bar */
.sap-header-bar {
    background: linear-gradient(180deg, #1d3b6f 0%, #152c54 100%);
    color: #ffffff;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 3px solid #f29f05;
}

.sap-header-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sap-window-controls {
    display: flex;
    gap: 8px;
    font-family: monospace;
    cursor: pointer;
    font-size: 13px;
}

/* Forms Layout Grid */
.sap-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding: 8px 12px;
}

.sap-form-grid > div {
    max-width: 480px;
    width: 100%;
}

.sap-form-grid > div:last-child {
    margin-left: auto;
}

.sap-form-group {
    display: flex;
    align-items: center;
    margin-bottom: 3px;
}

.sap-form-group label {
    width: 110px;
    min-width: 110px;
    color: #000000;
    font-size: 11px;
    font-weight: normal;
}

.sap-form-group-fields {
    display: flex;
    gap: 4px;
    width: 100%;
}

/* SAP B1 Inputs */
.sap-input, .sap-select {
    font-family: "Tahoma", sans-serif;
    font-size: 11px;
    height: 19px;
    border: 1px solid #7f9db9;
    padding: 1px 3px;
    box-sizing: border-box;
    background-color: #ffffff;
    color: #000000;
    border-radius: 0px;
    width: 100%;
}

.sap-input:focus, .sap-select:focus {
    outline: 1px solid #e89a00;
}

/* SAP Readonly Input Style (Yellow Fill) */
.sap-readonly {
    background-color: #ffffe1 !important;
    font-weight: bold;
    color: #000000 !important;
}

/* SAP Yellow Link Arrow */
.sap-link-arrow {
    display: inline-block;
    width: 11px;
    height: 11px;
    background-color: #e89a00;
    color: #000000;
    font-size: 8px;
    line-height: 11px;
    text-align: center;
    font-weight: bold;
    border-radius: 1px;
    margin-right: 4px;
    cursor: pointer;
}

/* Tab panels */
.sap-tabs-container {
    padding: 0 12px;
}

.sap-tab-headers {
    display: flex;
    border-bottom: 1px solid #808080;
    gap: 1px;
    overflow-x: auto;
}

.sap-tab-header {
    background-color: #cbd3dc;
    border: 1px solid #a0a0a0;
    border-bottom: none;
    padding: 2px 10px;
    cursor: pointer;
    font-size: 11px;
    border-radius: 2px 2px 0 0;
    white-space: nowrap;
    flex: 1;
    text-align: center;
    color: #000000 !important;
}

.sap-tab-header.active {
    background-color: #ebecee;
    font-weight: bold;
    border-top: 2px solid #e89a00;
    margin-bottom: -1px;
    border-bottom: 1px solid #ebecee;
}

.sap-tab-content {
    background-color: #ebecee;
    border: 1px solid #808080;
    border-top: none;
    padding: 8px;
}

/* Grid Table for Items matrix */
.sap-table-wrapper {
    overflow-x: auto;
    max-width: 100%;
    background-color: #ffffff;
    border: 1px solid #808080;
}

.sap-grid-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1350px;
}

.sap-grid-table th {
    background-color: #cbd3dc;
    border-right: 1px solid #a0a0a0;
    border-bottom: 1px solid #808080;
    font-weight: bold;
    font-size: 11px;
    text-align: left;
    padding: 2px 4px;
    color: #000000;
}

.sap-grid-table td {
    border-right: 1px solid #d0d0d0;
    border-bottom: 1px solid #e0e0e0;
    padding: 1px 3px;
    height: 22px;
}

.sap-col-shaded {
    background-color: #f1f3f6 !important;
}

.sap-grid-table tr:nth-child(even) {
    background-color: #f2f6fb;
}

.sap-grid-table tr:nth-child(odd) {
    background-color: #ffffff;
}

/* Footer sections */
.sap-footer {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 40px;
    padding: 10px 12px;
}

.sap-footer > div:first-child {
    max-width: 550px;
    width: 100%;
}

.sap-footer > div:last-child {
    max-width: 480px;
    width: 100%;
    margin-left: auto;
}

.sap-summary-box {
    background-color: #e2e6eb;
    border: 1px solid #a0a0a0;
    padding: 8px;
    border-radius: 2px;
}

/* Action Buttons bar */
.sap-actions-bar {
    background-color: #ebecee;
    border-top: 1px solid #cbd3dc;
    padding: 6px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sap-actions-left, .sap-actions-right {
    display: flex;
    gap: 6px;
}

.sap-btn {
    font-family: "Tahoma", sans-serif;
    font-size: 11px;
    height: 20px;
    padding: 0 12px;
    border-radius: 2px;
    cursor: pointer;
    box-sizing: border-box;
    line-height: 18px;
}

.sap-btn-primary {
    background: linear-gradient(180deg, #1d3b6f 0%, #152c54 100%);
    color: #ffffff;
    border: 1px solid #0f243e;
    font-weight: bold;
}

.sap-btn-secondary {
    background: linear-gradient(180deg, #f0f0f0 0%, #e0e0e0 100%);
    color: #000000;
    border: 1px solid #7f9db9;
}

.sap-btn-disabled {
    background-color: #e0e0e0 !important;
    color: #808080 !important;
    border: 1px solid #b5b5b5 !important;
    cursor: not-allowed;
}

/* Responsiveness Media Queries */
@media (max-width: 1024px) {
    .sap-form-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .sap-footer {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
}
