/* ============================================================
   EMPLOYEE TABLE COMPONENT
   .et-* classes for the directory table, load-more footer,
   skeleton loaders, context menu, and empty state.
   .ef-* classes for the filter bar (EmployeeFilters component).
   ============================================================ */

/* ── Table container ──────────────────────────────────────── */
.et-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ── Table scroll wrapper ─────────────────────────────────── */
.et-scroll {
    overflow-y: auto;
    overflow-x: hidden;
}

.et-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

/* ── Header ───────────────────────────────────────────────── */
.et-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--color-background);
}

.et-table th {
    padding: 10px 16px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

/* Column widths - auto-sized, but we can nudge fixed ones */
.et-col-actions {
    text-align: center !important;
    white-space: nowrap;
}

/* ── Rows ─────────────────────────────────────────────────── */
.et-table tbody tr {
    cursor: pointer;
    transition: background-color var(--transition-fast);
    border-bottom: 1px solid var(--color-border);
}

.et-table tbody tr:last-child {
    border-bottom: none;
}

.et-table tbody tr:hover {
    background-color: var(--color-background);
}

.et-table tbody tr.et-row-selected {
    background-color: var(--color-background);
    box-shadow: inset 3px 0 0 var(--color-accent);
}

.et-table tbody tr.et-row-selected:hover {
    background-color: var(--color-accent-subtle);
}

.et-table tbody tr.et-row--inactive {
    opacity: 0.6;
}

.et-table tbody tr.et-row--removed {
    opacity: 0.5;
    background-color: var(--color-error-subtle);
}

.et-table tbody tr.et-row--removed:hover {
    background-color: var(--color-error-subtle);
}

.et-table td {
    padding: 10px 16px;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.et-muted {
    color: var(--color-text-secondary);
}

/* ── Employee cell (avatar + name + email) ────────────────── */
.et-employee-cell {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.et-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    background: var(--color-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    overflow: hidden;
    text-transform: uppercase;
}

.et-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

.et-name-group {
    flex: 1;
    min-width: 0;
}

.et-name {
    font-weight: 500;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.et-email {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Role badge ───────────────────────────────────────────── */
.et-role-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
    white-space: nowrap;
}

.et-role-badge.et-role-owner {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
}

.et-role-badge.et-role-admin {
    background: var(--color-background);
    color: #374151;
    border: 1px solid var(--color-border);
}

.et-role-badge.et-role-manager {
    background: var(--color-success-subtle);
    color: var(--color-success);
}

.et-role-badge.et-role-employee {
    background: var(--color-background);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

/* ── Status indicator ─────────────────────────────────────── */
.et-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.et-status-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.et-status-dot.active   { background: var(--color-success); }
.et-status-dot.inactive { background: #D1D5DB; }
.et-status-dot.removed  { background: var(--color-error); }
.et-status.active   { color: var(--color-success); }
.et-status.inactive { color: var(--color-text-secondary); }
.et-status.removed  { color: var(--color-error); }

/* ── Actions cell ─────────────────────────────────────────── */
.et-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.et-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    border-radius: var(--legacy-radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
    padding: 0;
    flex-shrink: 0;
}

.et-action-btn--ghost {
    color: var(--color-text-secondary);
}

.et-action-btn--ghost:hover {
    background: var(--color-background);
    color: var(--color-text-primary);
}

.et-action-btn--warning {
    color: var(--color-warning);
}

.et-action-btn--warning:hover {
    background: var(--color-warning-subtle);
    color: var(--color-warning-hover);
}

.et-action-btn--success {
    color: var(--color-success);
}

.et-action-btn--success:hover {
    background: var(--color-success-subtle);
    color: var(--color-success-hover);
}

.et-action-btn--danger {
    color: var(--color-error);
}

.et-action-btn--danger:hover {
    background: var(--color-error-subtle);
    color: var(--color-error-hover);
}

/* ── Empty state ──────────────────────────────────────────── */
.et-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 2rem;
    text-align: center;
}

.et-empty-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: var(--color-background);
    color: #D1D5DB;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
}

.et-empty-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 var(--space-1);
}

.et-empty-hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin: 0;
}

/* ── Skeleton loaders ─────────────────────────────────────── */
.et-skeleton-row td {
    padding: 10px 16px;
}

.et-skel {
    border-radius: var(--legacy-radius-sm);
    background: linear-gradient(90deg,
        var(--color-border) 25%,
        var(--color-background) 50%,
        var(--color-border) 75%);
    background-size: 200% 100%;
    animation: et-shimmer 1.4s ease infinite;
}

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

.et-skel-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.et-skel-text    { height: 12px; width: 80%; }
.et-skel-text-sm { height: 10px; width: 60%; margin-top: 4px; }
.et-skel-badge   { height: 20px; width: 60px; border-radius: var(--radius-full); }

/* ── Load-more footer ─────────────────────────────────────── */
.et-load-more-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-5) var(--space-4);
    border-top: 1px solid var(--color-border);
}

.et-count-text {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin: 0;
}

.et-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.et-load-more-btn:hover:not(:disabled) {
    border-color: var(--color-accent);
    background: var(--color-accent-subtle);
    color: var(--color-accent);
}

.et-load-more-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.et-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: et-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Filter bar (.ef-*) ───────────────────────────────────── */
.ef-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

/* Search input wrapper */
.ef-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.ef-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.ef-search-input {
    width: 100%;
    padding: var(--space-2) 32px var(--space-2) 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ef-search-input::placeholder {
    color: var(--color-text-secondary);
}

.ef-search-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.ef-clear-input-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: var(--color-background);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast);
    padding: 0;
}

.ef-clear-input-btn:hover {
    color: var(--color-text-primary);
    background: var(--color-border);
}

/* Department / Location / Role selects */
.ef-select {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
    white-space: nowrap;
}

.ef-select:focus {
    border-color: var(--color-accent);
}

/* Status pills group */
.ef-status-pills {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
}

.ef-pill {
    padding: var(--space-2) var(--space-3);
    border: none;
    border-right: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.ef-pill:last-child {
    border-right: none;
}

.ef-pill:hover {
    background: var(--color-background);
    color: var(--color-text-primary);
}

.ef-pill--on {
    background: var(--color-accent);
    color: #fff;
}

.ef-pill--on:hover {
    background: var(--color-accent-hover);
    color: #fff;
}

/* Clear filters link */
.ef-clear-link {
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-family: inherit;
    cursor: pointer;
    padding: var(--space-2) var(--space-1);
    white-space: nowrap;
    transition: color var(--transition-fast);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ef-clear-link:hover {
    color: var(--color-text-primary);
}

/* ── Mobile: hide lower-priority columns ──────────────────── */
@media (max-width: 768px) {
    .et-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .et-table {
        font-size: 13px;
        min-width: 380px;
    }

    .et-col-dept,
    .et-col-location,
    .et-col-joined,
    .et-col-actions,
    .et-table th.et-col-dept,
    .et-table th.et-col-location,
    .et-table th.et-col-joined,
    .et-table th.et-col-actions,
    .et-table td.et-col-dept,
    .et-table td.et-col-location,
    .et-table td.et-col-joined,
    .et-table td.et-col-actions {
        display: none;
    }

    .ef-search-wrap {
        flex: 1 1 100%;
        min-width: 0;
    }

    .ef-select {
        flex: 1;
    }
}

@media (max-width: 640px) {
    .et-table th,
    .et-table td {
        padding: 8px 10px;
        font-size: 12px;
    }

    .et-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
}

@media (max-width: 400px) {
    /* Hide Status column — only Name + Role remain */
    .et-col-status,
    .et-table th.et-col-status,
    .et-table td.et-col-status {
        display: none;
    }
}
