/* NpTable - enterprise data table styling */

.np-table-card {
    background: #fff;
    border: 1px solid #e5e9f2;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
    overflow: hidden;
}

/* ---------- Toolbar ---------- */
.np-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid #eef1f6;
    flex-wrap: wrap;
}

.np-table-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
}

.np-table-count {
    display: inline-block;
    margin-left: 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #2563eb;
    background: #eff6ff;
    border-radius: 20px;
    padding: 0.15rem 0.6rem;
}

.np-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.np-search-box {
    position: relative;
    width: 240px;
}

.np-search-box .np-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.85rem;
}

.np-search-box input {
    width: 100%;
    border: 1px solid #e5e9f2;
    border-radius: 8px;
    padding: 0.45rem 2rem 0.45rem 2.1rem;
    font-size: 0.85rem;
    background: #f9fafb;
    transition: all 0.15s ease;
    outline: none;
}

.np-search-box input:focus {
    background: #fff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.np-search-clear {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    color: #9ca3af;
    font-size: 0.7rem;
    padding: 0.2rem;
    cursor: pointer;
}

.np-tool-btn {
    border: 1px solid #e5e9f2;
    background: #fff;
    color: #4b5563;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.np-tool-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.np-tool-btn.active {
    background: #eff6ff;
    border-color: #2563eb;
    color: #2563eb;
}

/* ---------- Dropdowns ---------- */
.np-dropdown {
    position: relative;
}

.np-dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1049;
}

.np-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 1050;
    min-width: 190px;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e9f2;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(16, 24, 40, 0.12);
    padding: 0.35rem;
}

.np-dropdown-header {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    padding: 0.4rem 0.6rem;
}

.np-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.42rem 0.6rem;
    font-size: 0.85rem;
    color: #374151;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    margin: 0;
}

.np-dropdown-item:hover {
    background: #f3f4f6;
}

.np-dropdown-item input[type="checkbox"] {
    accent-color: #2563eb;
}

/* ---------- Table ---------- */
.np-table-scroll {
    overflow-x: auto;
    position: relative;
    min-height: 10rem;
}

.np-table-scroll.is-loading {
    overflow: hidden;
}

.np-table-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(1px);
    pointer-events: none;
}

.np-table-loading-spacer td {
    height: 10rem;
    border: none !important;
    padding: 0 !important;
}

.np-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.np-table thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e9f2;
    white-space: nowrap;
    user-select: none;
}

.np-th-inner {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.np-th-inner.sortable {
    cursor: pointer;
}

.np-sort-icon {
    font-size: 0.7rem;
    color: #cbd5e1;
}

.np-sort-icon.active {
    color: #2563eb;
}

.np-filter-row th {
    padding: 0.35rem 0.6rem;
    background: #fdfefe;
}

.np-filter-input {
    width: 100%;
    min-width: 90px;
    border: 1px solid #e5e9f2;
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    outline: none;
}

.np-filter-input:focus {
    border-color: #2563eb;
}

.np-table tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
    white-space: nowrap;
}

.np-table tbody tr:last-child td {
    border-bottom: none;
}

.np-table tbody tr:hover {
    background: #f8fafc;
}

/* Compact single-line action buttons */
.np-actions-row {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.25rem;
    white-space: nowrap;
}

.np-actions-row .np-btn {
    flex-shrink: 0;
}

.np-actions-row .dropdown {
    display: inline-flex;
}

.np-actions-toggle {
    color: #64748b !important;
}

/* Floating More menu (rendered outside table overflow) */
.np-more-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1080;
    background: transparent;
}

.np-more-menu {
    position: fixed;
    z-index: 1081;
    min-width: 200px;
    background: #fff;
    border: 1px solid #e5e9f2;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.14);
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.np-more-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: #374151;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.45rem 0.7rem;
    border-radius: 7px;
    text-decoration: none;
    cursor: pointer;
}

.np-more-menu-item:hover {
    background: #f3f4f6;
    color: #111827;
}

.np-more-menu-item.text-danger {
    color: #dc2626;
}

.np-more-menu-item.text-danger:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.np-more-menu-divider {
    height: 1px;
    background: #eef1f6;
    margin: 0.25rem 0.35rem;
}

/* Uniform editable controls in charge slab tables (component styles also enforce this) */
.np-table .np-slab-control {
    width: 100%;
    min-width: 110px;
    height: 31px !important;
    min-height: 31px !important;
    max-height: 31px !important;
    box-sizing: border-box !important;
    font-size: 0.875rem !important;
    line-height: 1.5 !important;
    padding: 0.25rem 0.5rem !important;
}

.np-table select.np-slab-control {
    padding-right: 1.75rem !important;
    background-image: none !important;
}

.np-slab-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-width: 110px;
    white-space: nowrap;
}

.np-row-clickable {
    cursor: pointer;
}

.np-th-rownum,
.np-td-rownum {
    width: 48px;
    color: #94a3b8 !important;
    text-align: center;
}

/* ---------- States ---------- */
.np-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 3rem 1rem;
    text-align: center;
}

/* Keep empty-state content in the visible scroll viewport on wide tables */
.np-state-viewport {
    position: sticky;
    left: 0;
    width: max(16rem, 40vw);
    max-width: 100%;
    margin-inline: auto;
    box-sizing: border-box;
}

.np-state-icon {
    font-size: 2.5rem;
    color: #cbd5e1;
}

.np-state-title {
    font-weight: 600;
    color: #475569;
}

.np-state-sub {
    font-size: 0.8rem;
    color: #94a3b8;
}

/* Framework-agnostic loading spinner (no Bootstrap dependency) */
.np-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(37, 99, 235, 0.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: np-spin 0.7s linear infinite;
}

@keyframes np-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Footer / pagination ---------- */
.np-table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #eef1f6;
    flex-wrap: wrap;
}

.np-footer-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.8rem;
    color: #64748b;
}

.np-pagesize {
    border: 1px solid #e5e9f2;
    border-radius: 6px;
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
    color: #374151;
    background: #fff;
    outline: none;
}

.np-entries {
    white-space: nowrap;
}

.np-pager {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.np-page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 0.4rem;
    border: 1px solid #e5e9f2;
    background: #fff;
    color: #4b5563;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.np-page-btn:hover:not(:disabled):not(.active) {
    background: #f3f4f6;
}

.np-page-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    font-weight: 600;
}

.np-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---------- Status badge helpers (usable in cell templates) ---------- */
.np-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    white-space: nowrap;
}

.np-badge-success { background: #ecfdf5; color: #059669; }
.np-badge-danger  { background: #fef2f2; color: #dc2626; }
.np-badge-warning { background: #fffbeb; color: #d97706; }
.np-badge-info    { background: #eff6ff; color: #2563eb; }
.np-badge-neutral { background: #f3f4f6; color: #4b5563; }

/* ---------- Page-level helpers (filter panel / page header) ---------- */
.np-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.np-page-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.np-page-header .np-page-sub {
    font-size: 0.83rem;
    color: #6b7280;
    margin-top: 0.15rem;
}

.np-filter-panel {
    background: #fff;
    border: 1px solid #e5e9f2;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.np-filter-panel .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    margin-bottom: 0.3rem;
}

.np-filter-panel .form-control,
.np-filter-panel .form-select {
    font-size: 0.85rem !important;
    border-color: #e5e9f2 !important;
    border-radius: 8px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0.375rem 0.75rem !important;
    line-height: 1.5 !important;
    box-sizing: border-box !important;
}

.np-filter-panel .form-select {
    padding-right: 2rem !important;
    background-size: 16px 12px !important;
    background-position: right 0.75rem center !important;
}

.np-filter-panel .form-control:focus,
.np-filter-panel .form-select:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

.np-filter-panel .np-btn {
    height: 38px;
    min-height: 38px;
    box-sizing: border-box;
}

.np-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.45rem 1rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.np-btn-primary {
    background: #2563eb;
    color: #fff;
}

.np-btn-primary:hover {
    background: #1d4ed8;
    color: #fff;
}

.np-btn-outline {
    background: #fff;
    border-color: #e5e9f2;
    color: #374151;
}

.np-btn-outline:hover {
    background: #f3f4f6;
}

.np-btn-outline.active {
    background: #eff6ff;
    border-color: #2563eb;
    color: #2563eb;
}

@media (max-width: 768px) {
    .np-table-toolbar,
    .np-table-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .np-search-box {
        width: 100%;
    }

    .np-pager {
        justify-content: center;
    }
}

/* ---------- Dark mode (Tailwind 'dark' class on body, retailer/admin theme) ---------- */
.dark .np-table-card,
.dark .np-filter-panel {
    background: #1b2e4b;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}

.dark .np-table-toolbar,
.dark .np-table-footer {
    border-color: rgba(255, 255, 255, 0.08);
}

.dark .np-table-loading-overlay {
    background: rgba(27, 46, 75, 0.9);
}

.dark .np-table-title {
    color: #e2e8f0;
}

.dark .np-table-count {
    background: rgba(37, 99, 235, 0.18);
    color: #93c5fd;
}

.dark .np-search-box input,
.dark .np-filter-input,
.dark .np-pagesize,
.dark .np-tool-btn,
.dark .np-page-btn {
    background: #14243d;
    border-color: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
}

.dark .np-tool-btn:hover,
.dark .np-page-btn:hover:not(:disabled):not(.active) {
    background: #1e3a5f;
    color: #e2e8f0;
}

.dark .np-page-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.dark .np-dropdown-menu {
    background: #1b2e4b;
    border-color: rgba(255, 255, 255, 0.1);
}

.dark .np-dropdown-item {
    color: #cbd5e1;
}

.dark .np-dropdown-item:hover {
    background: #1e3a5f;
}

.dark .np-table thead th {
    background: #14243d;
    color: #94a3b8;
    border-color: rgba(255, 255, 255, 0.08);
}

.dark .np-filter-row th {
    background: #16283f;
}

.dark .np-table tbody td {
    color: #cbd5e1;
    border-color: rgba(255, 255, 255, 0.06);
}

.dark .np-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.dark .np-state-title {
    color: #cbd5e1;
}

.dark .np-footer-left {
    color: #94a3b8;
}
