/**
 * TBP Portal DataTable Styles
 *
 * @package TBP_Portal
 */

/* ========================================
   DataTable Container
   ======================================== */

.tbp-dt {
    background: var(--tbp-white);
    border-radius: var(--tbp-radius-lg);
    border: 1px solid var(--tbp-border-color);
    overflow: hidden;
}

/* ========================================
   Toolbar
   ======================================== */

.tbp-dt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--tbp-border-color);
    flex-wrap: wrap;
}

.tbp-dt-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tbp-dt-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Search Input */
.tbp-dt-search {
    position: relative;
}

.tbp-dt-search-input {
    width: 260px;
    padding: 8px 36px 8px 12px;
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tbp-dt-search-input:focus {
    outline: none;
    border-color: var(--tbp-accent-2);
    box-shadow: 0 0 0 3px rgba(92, 212, 214, 0.15);
}

.tbp-dt-search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--tbp-text-muted);
    pointer-events: none;
}

.tbp-dt-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tbp-border-color);
    border: none;
    border-radius: 50%;
    color: var(--tbp-text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.tbp-dt-search-input:not(:placeholder-shown) + .tbp-dt-search-icon {
    display: none;
}

.tbp-dt-search-input:not(:placeholder-shown) ~ .tbp-dt-search-clear {
    opacity: 1;
}

.tbp-dt-search-clear:hover {
    background: var(--tbp-text-muted);
    color: var(--tbp-white);
}

/* Toolbar Buttons */
.tbp-dt-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--tbp-white);
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-md);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--tbp-text);
    cursor: pointer;
    transition: all 0.2s;
}

.tbp-dt-btn:hover {
    background: var(--tbp-white-alt);
    border-color: var(--tbp-text-muted);
}

.tbp-dt-btn:active {
    transform: scale(0.98);
}

.tbp-dt-btn .ti {
    font-size: 16px;
}

.tbp-dt-btn-primary {
    background: var(--tbp-accent-1);
    border-color: var(--tbp-accent-1);
    color: var(--tbp-white);
}

.tbp-dt-btn-primary:hover {
    background: #D12E4A;
    border-color: #D12E4A;
}

/* Selected Count Badge */
.tbp-dt-selected-count {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(92, 212, 214, 0.1);
    border-radius: var(--tbp-radius-md);
    font-size: 13px;
    color: var(--tbp-text);
}

.tbp-dt-selected-count strong {
    color: var(--tbp-accent-2);
}

/* ========================================
   Table Wrapper
   ======================================== */

.tbp-dt-wrapper {
    overflow-x: auto;
}

/* ========================================
   Table
   ======================================== */

.tbp-dt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

/* Header */
.tbp-dt-thead {
    background: var(--tbp-white-alt);
}

.tbp-dt-thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--tbp-text);
    border-bottom: 1px solid var(--tbp-border-color);
    white-space: nowrap;
    position: relative;
}

.tbp-dt-thead th.tbp-dt-align-center {
    text-align: center;
}

.tbp-dt-thead th.tbp-dt-align-right {
    text-align: right;
}

/* Sticky Header */
.tbp-dt--sticky-header .tbp-dt-thead th {
    position: sticky;
    top: 0;
    background: var(--tbp-white-alt);
    z-index: 10;
}

/* Sortable Header */
.tbp-dt-sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.tbp-dt-sortable:hover {
    background: rgba(0, 0, 0, 0.03);
}

.tbp-dt-sort-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tbp-dt-sort-icon {
    font-size: 14px;
    color: var(--tbp-text-muted);
    transition: color 0.2s, transform 0.2s;
}

.tbp-dt-sort-icon.is-active {
    color: var(--tbp-accent-1);
}

/* Body */
.tbp-dt-tbody tr {
    transition: background 0.15s;
}

.tbp-dt--striped .tbp-dt-tbody tr:nth-child(even) {
    background: var(--tbp-white-alt);
}

.tbp-dt--hoverable .tbp-dt-tbody tr:hover {
    background: rgba(92, 212, 214, 0.05);
}

.tbp-dt-tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--tbp-border-color);
    color: var(--tbp-text);
    vertical-align: middle;
}

.tbp-dt-tbody td.tbp-dt-align-center {
    text-align: center;
}

.tbp-dt-tbody td.tbp-dt-align-right {
    text-align: right;
}

/* Compact Mode */
.tbp-dt--compact .tbp-dt-thead th,
.tbp-dt--compact .tbp-dt-tbody td {
    padding: 8px 12px;
}

/* Bordered */
.tbp-dt--bordered .tbp-dt-thead th,
.tbp-dt--bordered .tbp-dt-tbody td {
    border: 1px solid var(--tbp-border-color);
}

/* Row Selected */
.tbp-dt-tbody tr.is-selected {
    background: rgba(92, 212, 214, 0.1) !important;
}

/* Row Click */
.tbp-dt--row-clickable .tbp-dt-tbody tr {
    cursor: pointer;
}

/* ========================================
   Checkbox Column
   ======================================== */

.tbp-dt-checkbox-cell {
    width: 48px;
    text-align: center !important;
}

.tbp-dt-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--tbp-accent-2);
}

/* ========================================
   Expand Column (Nested Rows)
   ======================================== */

.tbp-dt-expand-cell {
    width: 48px;
    text-align: center !important;
}

.tbp-dt-expand-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--tbp-radius-sm);
    color: var(--tbp-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tbp-dt-expand-btn:hover {
    background: var(--tbp-white-alt);
    color: var(--tbp-text);
}

.tbp-dt-expand-btn .ti {
    font-size: 18px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tbp-dt-expand-btn.is-expanded .ti {
    transform: rotate(90deg);
}

.tbp-dt-expand-placeholder {
    width: 28px;
    display: inline-block;
}

/* Nested Row Indent */
.tbp-dt-nested-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tbp-dt-indent {
    flex-shrink: 0;
}

/* Nested Row Animation */
.tbp-dt-tbody tr.tbp-dt-nested-row {
    animation: tbp-dt-row-enter 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tbp-dt-row-enter {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Nested Level Indicator */
.tbp-dt-level-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tbp-dt-level-line {
    width: 1px;
    height: 20px;
    background: var(--tbp-border-color);
    margin-left: 12px;
}

/* ========================================
   Footer / Pagination
   ======================================== */

.tbp-dt-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    border-top: 1px solid var(--tbp-border-color);
    background: var(--tbp-white-alt);
    flex-wrap: wrap;
}

.tbp-dt-footer-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tbp-dt-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Page Size Select */
.tbp-dt-page-size {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--tbp-text-muted);
}

.tbp-dt-page-size select {
    padding: 6px 28px 6px 10px;
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--tbp-white);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* Showing Text */
.tbp-dt-showing {
    font-size: 13px;
    color: var(--tbp-text-muted);
}

/* Pagination */
.tbp-dt-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tbp-dt-page-btn {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    background: var(--tbp-white);
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--tbp-text);
    cursor: pointer;
    transition: all 0.2s;
}

.tbp-dt-page-btn:hover:not(:disabled):not(.is-active) {
    background: var(--tbp-white-alt);
    border-color: var(--tbp-text-muted);
}

.tbp-dt-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tbp-dt-page-btn.is-active {
    background: var(--tbp-accent-1);
    border-color: var(--tbp-accent-1);
    color: var(--tbp-white);
}

.tbp-dt-page-btn .ti {
    font-size: 16px;
}

.tbp-dt-page-dots {
    padding: 0 4px;
    color: var(--tbp-text-muted);
}

/* ========================================
   Loading State
   ======================================== */

.tbp-dt-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--tbp-text-muted);
}

.tbp-dt-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--tbp-border-color);
    border-top-color: var(--tbp-accent-2);
    border-radius: 50%;
    animation: tbp-dt-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

.tbp-dt-loading-text {
    font-size: 14px;
}

/* Loading Skeleton */
.tbp-dt-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
}

.tbp-dt-skeleton-row {
    display: flex;
    gap: 16px;
}

.tbp-dt-skeleton-cell {
    height: 16px;
    background: linear-gradient(90deg, var(--tbp-border-color) 25%, var(--tbp-white-alt) 50%, var(--tbp-border-color) 75%);
    background-size: 200% 100%;
    animation: tbp-dt-shimmer 1.5s infinite;
    border-radius: 4px;
    flex: 1;
}

@keyframes tbp-dt-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   Empty State
   ======================================== */

.tbp-dt-empty {
    text-align: center;
    padding: 60px 20px;
}

.tbp-dt-empty-icon {
    font-size: 48px;
    color: var(--tbp-border-color);
    margin-bottom: 12px;
}

.tbp-dt-empty-title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
    color: var(--tbp-text);
}

.tbp-dt-empty-text {
    margin: 0;
    font-size: 14px;
    color: var(--tbp-text-muted);
}

/* ========================================
   Column Filters (Header)
   ======================================== */

.tbp-dt-column-filter {
    margin-top: 8px;
}

.tbp-dt-column-filter input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-sm);
    font-size: 12px;
    font-family: inherit;
}

.tbp-dt-column-filter input:focus {
    outline: none;
    border-color: var(--tbp-accent-2);
}

/* ========================================
   Actions Column
   ======================================== */

.tbp-dt-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

.tbp-dt-action {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--tbp-radius-sm);
    color: var(--tbp-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tbp-dt-action:hover {
    background: var(--tbp-white-alt);
    color: var(--tbp-text);
}

.tbp-dt-action--danger:hover {
    background: rgba(231, 55, 85, 0.1);
    color: var(--tbp-accent-1);
}

.tbp-dt-action .ti {
    font-size: 18px;
}

/* ========================================
   Responsive / Mobile Cards
   ======================================== */

.tbp-dt-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.tbp-dt-card {
    background: var(--tbp-white);
    border: 1px solid var(--tbp-border-color);
    border-radius: var(--tbp-radius-md);
    padding: 16px;
    transition: box-shadow 0.2s;
}

.tbp-dt-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tbp-dt-card.is-selected {
    border-color: var(--tbp-accent-2);
    background: rgba(92, 212, 214, 0.05);
}

.tbp-dt-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.tbp-dt-card-checkbox {
    margin-right: 12px;
}

.tbp-dt-card-title {
    font-weight: 600;
    color: var(--tbp-text);
    flex: 1;
}

.tbp-dt-card-expand {
    margin-left: auto;
}

.tbp-dt-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tbp-dt-card-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.tbp-dt-card-label {
    color: var(--tbp-text-muted);
}

.tbp-dt-card-value {
    color: var(--tbp-text);
    text-align: right;
}

.tbp-dt-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--tbp-border-color);
}

/* Nested Cards */
.tbp-dt-card.tbp-dt-nested-card {
    margin-left: 24px;
    border-left: 3px solid var(--tbp-accent-2);
}

/* ========================================
   Responsive Breakpoints
   ======================================== */

@media (max-width: 768px) {
    .tbp-dt-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .tbp-dt-toolbar-left,
    .tbp-dt-toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .tbp-dt-search {
        width: 100%;
    }

    .tbp-dt-search-input {
        width: 100%;
    }

    .tbp-dt-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .tbp-dt-footer-left,
    .tbp-dt-footer-right {
        justify-content: center;
    }
}

/* ========================================
   Badge Styles (for status columns etc)
   ======================================== */

.tbp-dt-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--tbp-radius-full);
}

.tbp-dt-badge--default {
    background: var(--tbp-white-alt);
    color: var(--tbp-text-muted);
}

.tbp-dt-badge--success {
    background: #ECFDF5;
    color: #059669;
}

.tbp-dt-badge--warning {
    background: #FFFBEB;
    color: #D97706;
}

.tbp-dt-badge--danger {
    background: #FEF2F2;
    color: #DC2626;
}

.tbp-dt-badge--info {
    background: #EFF6FF;
    color: #2563EB;
}

/* ========================================
   Avatar Cell
   ======================================== */

.tbp-dt-avatar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tbp-dt-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--tbp-white-alt);
}

.tbp-dt-avatar-initials {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tbp-accent-2);
    color: var(--tbp-primary);
    font-weight: 600;
    font-size: 13px;
    border-radius: 50%;
}

.tbp-dt-avatar-info {
    display: flex;
    flex-direction: column;
}

.tbp-dt-avatar-name {
    font-weight: 500;
    color: var(--tbp-text);
}

.tbp-dt-avatar-sub {
    font-size: 12px;
    color: var(--tbp-text-muted);
}

/* ========================================
   Transitions & Animations
   ======================================== */

.tbp-dt-fade-enter {
    opacity: 0;
}

.tbp-dt-fade-enter-active {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.tbp-dt-fade-leave-active {
    opacity: 0;
    transition: opacity 0.2s ease;
}
