/*
 * WMS - DataTable state styles (error / connection / permission states).
 * Loaded globally from resources/views/panels/styles.blade.php and used by
 * public/js/scripts/datatable-error.js. Every class is prefixed with "wms-dt-"
 * so it never collides with theme or plugin styles.
 */

/* ---------------------------------------------------------------- inline state */
/* DataTables shrinks an empty table to its header width - keep it full width
   while the error state is on screen so the message is not squeezed. */
table.dataTable.wms-dt-has-error {
    width: 100% !important;
}

tr.wms-dt-error-row > td {
    padding: 0 !important;
    background-color: transparent !important;
    border-top: 0 !important;
}

.wms-dt-state {
    display: block;
    max-width: 34rem;
    margin: 0 auto;
    padding: 2.75rem 1.5rem 2.5rem;
    text-align: center;
    white-space: normal;
    color: #626262;
}

.wms-dt-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    margin-bottom: 1.1rem;
    border-radius: 50%;
    background-color: rgba(234, 84, 85, 0.12);
    color: #ea5455;
}

.wms-dt-state-icon i,
.wms-dt-state-icon svg {
    font-size: 1.7rem;
    width: 1.7rem;
    height: 1.7rem;
    stroke-width: 2;
}

.wms-dt-state-warning .wms-dt-state-icon {
    background-color: rgba(255, 159, 67, 0.12);
    color: #ff9f43;
}

.wms-dt-state-info .wms-dt-state-icon {
    background-color: rgba(115, 103, 240, 0.12);
    color: #7367f0;
}

.wms-dt-state-title {
    margin-bottom: 0.4rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: #4b4b4b;
    letter-spacing: 0.2px;
}

.wms-dt-state-text {
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #82868b;
}

.wms-dt-state-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* gap fallback for older webkit builds */
.wms-dt-state-actions > * {
    margin: 0.25rem;
}

.wms-dt-state-actions .btn {
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
}

.wms-dt-state-actions .btn i,
.wms-dt-alert .btn i {
    margin-right: 0.35rem;
    font-size: 0.95rem;
}

/* ---------------------------------------------------------------- technical detail */
.wms-dt-detail {
    margin-top: 1.1rem;
    text-align: center;
}

.wms-dt-alert .wms-dt-detail {
    margin-top: 0.5rem;
    text-align: left;
}

.wms-dt-detail-toggle {
    display: inline-block;
    font-size: 0.8rem;
    color: #b8c2cc;
    text-decoration: none;
    cursor: pointer;
    border-bottom: 1px dashed rgba(184, 194, 204, 0.7);
}

.wms-dt-detail-toggle:hover,
.wms-dt-detail-toggle:focus {
    color: #7367f0;
    border-bottom-color: rgba(115, 103, 240, 0.7);
    text-decoration: none;
}

.wms-dt-detail-body {
    display: none;
    position: relative;
    margin-top: 0.75rem;
    padding: 0.85rem 1rem;
    max-height: 11rem;
    overflow: auto;
    border-radius: 0.4rem;
    background-color: #f8f8f8;
    border: 1px solid #ebe9f1;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.75rem;
    line-height: 1.65;
    color: #6e6b7b;
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;
}

.wms-dt-detail.is-open .wms-dt-detail-body {
    display: block;
}

.wms-dt-detail-copy {
    display: none;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.7rem;
}

.wms-dt-detail.is-open .wms-dt-detail-copy {
    display: inline-block;
}

/* ---------------------------------------------------------------- slim banner (table still has data) */
.wms-dt-alert {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.4rem;
    background-color: rgba(234, 84, 85, 0.08);
    border: 1px solid rgba(234, 84, 85, 0.25);
    color: #6e6b7b;
    font-size: 0.875rem;
    line-height: 1.5;
}

.wms-dt-alert > i:first-child {
    flex: 0 0 auto;
    margin-right: 0.65rem;
    margin-top: 0.1rem;
    font-size: 1.05rem;
    color: #ea5455;
}

.wms-dt-alert-body {
    flex: 1 1 auto;
    min-width: 0;
}

.wms-dt-alert-title {
    display: block;
    font-weight: 600;
    color: #4b4b4b;
}

.wms-dt-alert-actions {
    flex: 0 0 auto;
    margin-left: 0.75rem;
    white-space: nowrap;
}

.wms-dt-alert-actions .btn + .btn {
    margin-left: 0.4rem;
}

.wms-dt-alert-close {
    padding: 0 0 0 0.5rem;
    border: 0;
    background: none;
    color: #b8c2cc;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.wms-dt-alert-close:hover {
    color: #6e6b7b;
}

/* ---------------------------------------------------------------- busy state on retry */
.wms-dt-busy {
    pointer-events: none;
    opacity: 0.65;
}

.wms-dt-spin {
    display: inline-block;
    animation: wms-dt-spin 0.9s linear infinite;
}

@keyframes wms-dt-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------- export history layout */
/* Applied automatically by datatable-error.js to the shared five-column
   export-history format: Filter Params, Created At, Created By, File, Status. */
.wms-dt-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.dataTable.wms-dt-export-history {
    table-layout: fixed;
    width: 100% !important;
    min-width: 900px;
}

table.dataTable.wms-dt-export-history th,
table.dataTable.wms-dt-export-history td {
    vertical-align: top;
}

table.dataTable.wms-dt-export-history th:nth-child(1),
table.dataTable.wms-dt-export-history td:nth-child(1) {
    width: 40% !important;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

table.dataTable.wms-dt-export-history th:nth-child(2),
table.dataTable.wms-dt-export-history td:nth-child(2) {
    width: 15% !important;
}

table.dataTable.wms-dt-export-history th:nth-child(3),
table.dataTable.wms-dt-export-history td:nth-child(3) {
    width: 15% !important;
}

table.dataTable.wms-dt-export-history th:nth-child(4),
table.dataTable.wms-dt-export-history td:nth-child(4) {
    width: 20% !important;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

table.dataTable.wms-dt-export-history th:nth-child(5),
table.dataTable.wms-dt-export-history td:nth-child(5) {
    width: 10% !important;
}

/* ---------------------------------------------------------------- dark layout */
.dark-layout .wms-dt-state-title,
.dark-layout .wms-dt-alert-title {
    color: #d0d2d6;
}

.dark-layout .wms-dt-state,
.dark-layout .wms-dt-state-text,
.dark-layout .wms-dt-alert {
    color: #b4b7bd;
}

.dark-layout .wms-dt-detail-body {
    background-color: #10163a;
    border-color: #3b4253;
    color: #b4b7bd;
}

/* ---------------------------------------------------------------- small screens */
@media (max-width: 575.98px) {
    .wms-dt-state {
        padding: 2rem 1rem;
    }

    .wms-dt-alert {
        flex-wrap: wrap;
    }

    .wms-dt-alert-actions {
        margin-left: 0;
        margin-top: 0.5rem;
        width: 100%;
    }
}
