/* ════════════════════════════════════════════════════════════════════
   user-management.css
   Thêm vào wwwroot/css/ và import trong UserManagement.razor:
   <link rel="stylesheet" href="css/user-management.css" />
════════════════════════════════════════════════════════════════════ */

/* ── Page layout ────────────────────────────────────────────────── */

.um-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #111827);
    font-size: 13px;
}

.um-unauthorized {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 12px;
    color: var(--text-secondary, #6b7280);
    font-size: 15px;
}

/* ── Header ─────────────────────────────────────────────────────── */

.um-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}

.um-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.um-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
}

.um-count {
    font-size: 11px;
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-secondary, #6b7280);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 400;
}

/* ── Filters ────────────────────────────────────────────────────── */

.um-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}

.um-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 320px;
}

    .um-search-wrap svg {
        position: absolute;
        left: 10px;
        color: var(--text-secondary, #9ca3af);
        pointer-events: none;
    }

.um-search {
    width: 100%;
    padding: 7px 32px 7px 32px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 7px;
    font-size: 13px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
}

    .um-search:focus {
        outline: none;
        border-color: #6366f1;
    }

.um-search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-secondary, #9ca3af);
    line-height: 1;
}

.um-select {
    padding: 6px 10px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 7px;
    font-size: 13px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
    cursor: pointer;
}

/* ── Table ──────────────────────────────────────────────────────── */

.um-table-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
}

.um-loading, .um-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 20px;
    color: var(--text-secondary, #6b7280);
}

.um-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

    .um-table th {
        text-align: left;
        padding: 8px 12px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-secondary, #6b7280);
        border-bottom: 1px solid var(--border, #e5e7eb);
        white-space: nowrap;
    }

.um-row td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border, #f3f4f6);
    vertical-align: middle;
}

.um-row:hover td {
    background: var(--bg-hover, #f9fafb);
}

.um-row.self td {
    background: #faf5ff;
}

/* ── User cell ──────────────────────────────────────────────────── */

.um-user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.um-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    color: #fff;
}

    .um-avatar.admin {
        background: #6366f1;
    }

    .um-avatar.editor {
        background: #f59e0b;
    }

    .um-avatar.user {
        background: #6b7280;
    }

.um-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.um-username {
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.um-email {
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.um-note {
    font-size: 11px;
    cursor: help;
}

/* ── Tags ───────────────────────────────────────────────────────── */

.um-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
}

    .um-tag.self {
        background: #e0e7ff;
        color: #3730a3;
    }

    .um-tag.warn {
        background: #fef3c7;
        color: #92400e;
        cursor: help;
    }

/* ── Role badge ─────────────────────────────────────────────────── */

.um-role-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 5px;
    white-space: nowrap;
}

    .um-role-badge.admin {
        background: #e0e7ff;
        color: #3730a3;
    }

    .um-role-badge.editor {
        background: #fef3c7;
        color: #92400e;
    }

    .um-role-badge.user {
        background: var(--bg-secondary, #f3f4f6);
        color: var(--text-secondary, #6b7280);
    }

/* ── Status ─────────────────────────────────────────────────────── */

.um-status-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.um-status {
    font-size: 11px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

    .um-status.active {
        color: #15803d;
    }

    .um-status.inactive {
        color: #6b7280;
    }

    .um-status.locked {
        color: #dc2626;
    }

.um-status-sub {
    font-size: 10px;
    font-weight: 400;
    color: #9ca3af;
}

.um-failed-count {
    font-size: 10px;
    color: #b45309;
    background: #fef3c7;
    padding: 1px 5px;
    border-radius: 4px;
    width: fit-content;
}

/* ── Auth badge ─────────────────────────────────────────────────── */

.um-auth-badge {
    font-size: 10px;
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-secondary, #6b7280);
    padding: 2px 6px;
    border-radius: 4px;
}

.um-date {
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
}

/* ── Row actions ────────────────────────────────────────────────── */

.um-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.um-row:hover .um-actions {
    opacity: 1;
}

/* ── Pagination ─────────────────────────────────────────────────── */

.um-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    padding: 16px 0 8px;
}

.um-page-info {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    margin-right: 8px;
}

.um-page-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 6px;
    background: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    transition: background 0.15s;
}

    .um-page-btn:hover {
        background: var(--bg-hover, #f3f4f6);
    }

    .um-page-btn.active {
        background: #6366f1;
        color: #fff;
        border-color: #6366f1;
    }

/* ── Drawer ─────────────────────────────────────────────────────── */

.um-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 700;
    display: flex;
    justify-content: flex-end;
}

.um-drawer {
    width: 420px;
    max-width: 100%;
    height: 100%;
    background: var(--bg-primary, #fff);
    border-left: 1px solid var(--border, #e5e7eb);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(0,0,0,0.12);
}

.um-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.um-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.um-drawer-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}

/* ── Form fields ────────────────────────────────────────────────── */

.um-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .um-field label {
        font-size: 12px;
        font-weight: 600;
        color: var(--text-primary, #374151);
    }

.um-required {
    color: #ef4444;
    margin-left: 2px;
}

.um-optional {
    font-weight: 400;
    color: var(--text-secondary, #9ca3af);
}

.um-input {
    padding: 8px 10px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 7px;
    font-size: 13px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

    .um-input:focus {
        outline: none;
        border-color: #6366f1;
    }

    .um-input.error {
        border-color: #ef4444;
    }

textarea.um-input {
    resize: none;
}

.um-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

    .um-input-wrap .um-input {
        padding-right: 36px;
    }

.um-eye-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.um-error {
    font-size: 11px;
    color: #ef4444;
}

.um-form-error {
    padding: 8px 12px;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 7px;
    font-size: 12px;
    color: #dc2626;
}

/* ── Toggles ────────────────────────────────────────────────────── */

.um-toggles {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.um-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}

    .um-toggle input[type="checkbox"] {
        display: none;
    }

.um-toggle-track {
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: var(--border, #d1d5db);
    flex-shrink: 0;
    position: relative;
    transition: background 0.2s;
}

    .um-toggle-track::after {
        content: '';
        position: absolute;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: #fff;
        top: 2px;
        left: 2px;
        transition: transform 0.2s;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }

.um-toggle input:checked + .um-toggle-track {
    background: #6366f1;
}

    .um-toggle input:checked + .um-toggle-track::after {
        transform: translateX(16px);
    }
