/* Table Component Styles */

/* Force table column widths and prevent squeezing */
table.striped {
    table-layout: fixed;
    width: 100%;
}

table.striped th,
table.striped td {
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 120px;
}

/* --- Shared for all th variants --- */
table.striped th.header,
table.striped th.sortable-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    padding: 0.75rem;
    font-weight: 600;
    color: #495057;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
    line-height: 1.2;
    text-align: left;
}

/* --- Regular header (non-clickable) --- */
table.striped th.header {
    border-bottom: 2px solid #adb5bd;
}

/* --- Sortable header (interactive) --- */
table.striped th.sortable-header {
    cursor: pointer;
    user-select: none;
    border-bottom: 2px solid #007bff;
    position: relative;
    transition: all 0.2s ease-in-out;
}

/* Hover-effect: just for sortable headers */
table.striped th.sortable-header:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Text and sort arrow */
table.striped .header-text {
    display: block;
    font-weight: 600;
    color: #495057;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
    line-height: 1.2;
}

table.striped .sort-arrow {
    font-size: 0.8rem;
    color: #6c757d;
    opacity: 0.7;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

table.striped th.sortable-header:hover .sort-arrow {
    opacity: 1;
    color: #007bff;
}

.td-buttons {
  vertical-align: middle; /* Centre within row */
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

/* button group center alignment */
.td-buttons .button-group {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  margin: 0;
  height: 100%;
  vertical-align: middle;
}

/* uniform button height and padding */
.td-buttons .btn,
.td-buttons .btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  padding: 0.25rem 0.5rem;
  margin: 0;
}

.status-dot {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #9ca3af;
    position: relative;
    font-size: 0; /* Hide text content, show only the dot */
    line-height: 0;
}

.status-dot.ok {
    background: #10b981;
}

.status-dot.error {
    background: #ef4444;
}

.status-dot::after {
    content: '';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    text-align: center;
    background-color: #000;
    color: #fff;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    z-index: 1000;
}

.status-dot:hover::after {
    display: block;
}

.status-dot.ok::after {
    content: 'healthy';
}

.status-dot.error::after {
    content: 'unhealthy';
}

/* Text truncation for table cells - reusable class */
table.striped td span.text-truncate {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    max-width: 100%;
}

/* Column resize handle */
table.striped th {
    position: relative;
}

table.striped th .resize-handle {
    position: absolute;
    right: -3px;
    top: 0;
    bottom: 0;
    width: 7px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}

table.striped th .resize-handle:hover,
table.striped th .resize-handle.resizing {
    background: rgba(0, 123, 255, 0.5);
}

/* Prevent text selection during resize */
table.striped.resizing {
    user-select: none;
    cursor: col-resize;
}

table.striped.resizing * {
    cursor: col-resize;
}

/* Dark mode styles for table headers */
@media (prefers-color-scheme: dark) {
    table.striped th.header,
    table.striped th.sortable-header {
        background: linear-gradient(135deg, #374151 0%, #475569 100%);
        border: 1px solid #475569;
        color: #f1f5f9;
    }

    table.striped th.header {
        border-bottom: 2px solid #6b7280;
    }

    table.striped th.sortable-header {
        border-bottom: 2px solid #60a5fa;
    }

    table.striped th.sortable-header:hover {
        background: linear-gradient(135deg, #475569 0%, #4b5563 100%);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }

    table.striped .header-text {
        color: #f1f5f9;
    }

    table.striped .sort-arrow {
        color: #b8c0cc;
    }

    table.striped th.sortable-header:hover .sort-arrow {
        color: #93c5fd;
    }

    table.striped td {
        color: #f1f5f9;
    }

    table.striped td a {
        color: #93c5fd;
    }

    table.striped td a:hover {
        color: #bfdbfe;
    }

    table.striped th .resize-handle:hover,
    table.striped th .resize-handle.resizing {
        background: #60a5fa;
    }
}