/* ==============================================================================
   Inizya Mudra — User Management Stylesheet
   Strict adherence to variables.css token architecture
   ============================================================================== */

/* Navigation Tabs */
.nav-tab-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-input-bg);
    padding: 4px;
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border);
}

.nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
}

.nav-tab:hover {
    color: var(--color-primary);
    background: rgba(255, 255, 255, 0.7);
}

.nav-tab.active {
    color: var(--color-primary);
    background: var(--color-surface);
    font-weight: var(--font-weight-bold);
    box-shadow: var(--box-shadow-sm);
    border: 1px solid var(--color-border);
}

.nav-tab.active i {
    color: var(--color-accent);
}

/* Page Header */
.page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* KPI Summary Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.kpi-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--box-shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

.kpi-info h3 {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    line-height: 1;
}

.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.kpi-icon.total { background: #f1f5f9; color: var(--color-text); }
.kpi-icon.staff { background: #dcfce7; color: var(--color-success); }
.kpi-icon.manager { background: #e0f2fe; color: #0284c7; }
.kpi-icon.owner { background: #fef9c3; color: #a16207; }

/* Filter Section */
.users-filters {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: var(--space-3);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    box-shadow: var(--box-shadow-sm);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 250px;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* User Table */
.users-table-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--box-shadow-sm);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    text-align: left;
}

.users-table th {
    background: #f8fafc;
    color: var(--color-text-muted);
    font-weight: var(--font-weight-bold);
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.users-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    vertical-align: middle;
}

.users-table tr:last-child td {
    border-bottom: none;
}

.users-table tr:hover {
    background: #fcfdfe;
}

/* User Avatar & Identity */
.user-identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-input-bg);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-bold);
    font-size: 0.85rem;
    border: 1px solid var(--color-border);
}

.user-name-text {
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
}

.user-you-badge {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: var(--font-weight-bold);
}

/* Role Badges */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.5px;
}

.role-badge.owner {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fef08a;
}

.role-badge.manager {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.role-badge.staff {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* Status Badges */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
}

.status-pill.active {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.status-pill.active .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
}

.status-pill.inactive {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.status-pill.inactive .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
}

/* Action Buttons */
.action-btn-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-action-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.85rem;
}

.btn-action-icon:hover:not(:disabled) {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: var(--color-bg);
}

.btn-action-icon.danger:hover:not(:disabled) {
    color: var(--color-danger);
    border-color: var(--color-danger);
    background: #fef2f2;
}

.btn-action-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Role Preview Box inside Modal */
.role-preview-box {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 12px 14px;
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.role-preview-title {
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.role-preview-box ul {
    margin: 0;
    padding-left: 18px;
}

.role-preview-box li {
    margin-bottom: 3px;
}

/* Hierarchy Toggle Switch & Badges */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-toggle {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 28px;
}

.slider-toggle:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch-toggle input:checked + .slider-toggle {
    background-color: var(--color-primary, #2c553f);
}

.switch-toggle input:focus + .slider-toggle {
    box-shadow: 0 0 0 3px rgba(44, 85, 63, 0.2);
}

.switch-toggle input:checked + .slider-toggle:before {
    transform: translateX(24px);
}

.badge-hierarchy {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge-hierarchy.badge-active {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-hierarchy.badge-inactive {
    background-color: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .users-filters {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }
    .filter-group {
        width: 100%;
        min-width: unset;
    }
    .filter-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    .filter-controls select,
    .filter-controls button {
        width: 100%;
    }
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: var(--space-2);
    }
    .kpi-card {
        padding: var(--space-2) var(--space-3);
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .users-table th,
    .users-table td {
        padding: 10px 12px;
    }
}

.btn-toggle-pwd {
    transition: color 0.15s ease;
}

.btn-toggle-pwd:hover {
    color: var(--color-primary) !important;
}

